I have a php script that I wrote that will use Drupal to validate the user login of a separate app that isn't part of Drupal. I have a php script that I want to put within the Drupal site. I can't seem to make .htaccess override the Drupal settings so that I can execute the php. Currently, I have, in the folder that holds the php:
# disable directory browsing Options All -Indexes AddHandler cgi-script .php AddType application/x-httpd-php .php AddHandler application/x-httpd-php .php
What should I do to enable my php script to execute? I've set the permissions to execute and I do get a listing of the php script file contents, which is not what I want. How can I make it execute?
Bill
William Prothero http://es.earthednet.org
I think you would be happier if you did this as a drupal module (it really is not that hard to do), than trying to hack the .htaccess file. Also drupal's .htaccess could be modified to point to your script rather than .php.
Implementing a custom module is really straightforward for what you need:
Create a subfolder in the sites/all/modules folder lets say sites/all/modules/mymodule Create a single .info file text file in that folder (mymodule.info) with the following text:
name = mymodule core = 7.x
Then create a mymodule.module file with a single function: function mymodule_init() { // your code that should execute on every drupal page load goes here. }
You can now enable this module in your drupal site and do what you need to do. As a general strategy, I'd recommend writing code that inspects for session variables or cookies set by the other application and if it doesn't find them redirects to the url either with drupal_goto() or with a header set. You can tell wether the drupal user is logged in by inspecting the global variable $user and seeing if it has a uid property.
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Prothero William Sent: Tuesday, February 11, 2014 4:41 PM To: support@drupal.org Subject: [support] .htaccess question I have a php script that I wrote that will use Drupal to validate the user login of a separate app that isn't part of Drupal. I have a php script that I want to put within the Drupal site. I can't seem to make .htaccess override the Drupal settings so that I can execute the php. Currently, I have, in the folder that holds the php:
# disable directory browsing Options All -Indexes AddHandler cgi-script .php AddType application/x-httpd-php .php AddHandler application/x-httpd-php .php
What should I do to enable my php script to execute? I've set the permissions to execute and I do get a listing of the php script file contents, which is not what I want. How can I make it execute?
Bill
William Prothero http://es.earthednet.org
I like this example on how to create a module,,,,Simple as it gets. http://cryptosmith.com/node/373
Phil
From: "Metzler, David" metzlerd@evergreen.edu To: "support@drupal.org" support@drupal.org, Date: 02/12/2014 11:32 AM Subject: Re: [support] .htaccess question Sent by: support-bounces@drupal.org
I think you would be happier if you did this as a drupal module (it really is not that hard to do), than trying to hack the .htaccess file. Also drupal's .htaccess could be modified to point to your script rather than .php.
Implementing a custom module is really straightforward for what you need:
Create a subfolder in the sites/all/modules folder lets say sites/all/modules/mymodule Create a single .info file text file in that folder (mymodule.info) with the following text:
name = mymodule core = 7.x
Then create a mymodule.module file with a single function: function mymodule_init() { // your code that should execute on every drupal page load goes here. }
You can now enable this module in your drupal site and do what you need to do. As a general strategy, I'd recommend writing code that inspects for session variables or cookies set by the other application and if it doesn't find them redirects to the url either with drupal_goto() or with a header set. You can tell wether the drupal user is logged in by inspecting the global variable $user and seeing if it has a uid property.
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Prothero William Sent: Tuesday, February 11, 2014 4:41 PM To: support@drupal.org Subject: [support] .htaccess question I have a php script that I wrote that will use Drupal to validate the user login of a separate app that isn't part of Drupal. I have a php script that I want to put within the Drupal site. I can't seem to make .htaccess override the Drupal settings so that I can execute the php. Currently, I have, in the folder that holds the php:
# disable directory browsing Options All -Indexes AddHandler cgi-script .php AddType application/x-httpd-php .php AddHandler application/x-httpd-php .php
What should I do to enable my php script to execute? I've set the permissions to execute and I do get a listing of the php script file contents, which is not what I want. How can I make it execute?
Bill
William Prothero http://es.earthednet.org
-- [ Drupal support list | http://lists.drupal.org/ ] -- [ Drupal support list | http://lists.drupal.org/ ]