Forum Moderators: phranque

Message Too Old, No Replies

application/x-httpd-php or application/x-httpd-php5

Getting my local server working the same as my host

         

SlimMillipede

5:26 pm on Nov 3, 2011 (gmt 0)

10+ Year Member



I have taken over an html website and am adding some php to every page, rather than renaming all the pages and having a whole heap of 301 redirects I decided to use;

AddHandler application/x-httpd-php .html .htm


Which worked fine on my local machine but not when I uploaded the changes to the live server (Hostgator), after a bit of searching I discovered that I needed to use;

AddHandler application/x-httpd-php5 .html .htm


This works fine but I would rather have both .htaccess files the same so I don't accidentally change something on the live site (or vice versa).

I am sure I can set up my development server to use the same syntax as the live server (they are both running php5 but my development server only has php5, there is no choice). But I don't know where to look to change this setting, is it in httpd.conf? or perhaps in php.ini?

Can anyone point me in the right direcetion?

Thanks

phranque

4:01 am on Nov 4, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



perhaps you could do something with the IfDefine directive and pass a parameter when invoking httpd to define your server as the local machine.
otherwise it acts like the live server.

http://httpd.apache.org/docs/2.0/mod/core.html#ifdefine

SlimMillipede

3:56 pm on Nov 4, 2011 (gmt 0)

10+ Year Member



Good idea, but I was hoping someone could tell me where the handler was set up so I could just change the name of the existing handler on my development machine to match that on the live site.

SlimMillipede

11:15 am on Nov 5, 2011 (gmt 0)

10+ Year Member



Well the answer appears simple now;

AddHandler application/x-httpd-php5 .php .html .htm


Adding .php to the list of extensions seems to make it work in both environments. No changes were required anywhere outside of the .htaccess file.

I'm not sure that I fully understand it but it works which is good for me.

SlimMillipede

11:04 am on Nov 7, 2011 (gmt 0)

10+ Year Member



Please ignore my previous post.

I obviously didn't test it properly and in the cold light of Monday morning the problem is still there. I do need to have .php in the list of file extensions but the MIME type still needs to be ...php in development and ...php5 in live.

SlimMillipede

12:49 pm on Dec 5, 2011 (gmt 0)

10+ Year Member



I have taken Phranque's advice but using IfModule instead of IfDefine. I run Windows on my development machine but my live server is Linux so I am able to use;

<IfModule mod_win32.c>
AddHandler application/x-httpd-php .php .html .htm
</IfModule>
<IfModule !mod_win32.c>
AddHandler application/x-httpd-php5 .php .html .htm
</IfModule>


So if the win32 module is installed it uses the first directive, otherwise the second.

It seems to work so far, thanks Phranque.