views:

498

answers:

3

My local development PC is set up to use PHP5 by default, my client's host (1and1.co.uk) is set up to use PHP4 by default.

To enable PHP5 on a 1and1 account, you must add the following line to your .htaccess file:

AddType x-mapp-php5 .php

If I add this line to my local .htaccess file, it breaks my PHP.

How do I add this line conditionally based on the domain (or some other parameter?) so it is only executed by the live site and not my dev site?

I'd like to be able to just upload (FTP) my entire source tree without worrying about having to remember to edit the .htaccess on the server ever time.

e.g.

<IfDomain www.example.com>
    AddType x-mapp-php5 .php
</IfDomain>

... rest of .htaccess

Is this possible?

I don't have access to the server config file, only .htaccess

Thanks in advance.

A: 

Try this. I have no idea whether it'll work. The terminology used in the documentation suggests that it should, but since no one ever does what you're trying to do, it's a little up in the air.

<Location http://www.example.com/&gt;
    AddType x-mapp-php5 .php
</Location>
chaos
Filled in a few more details so you have a better idea of what I am trying to achieve.
RichardAtHome
A: 

I know that you can do server-specific commands in httpd.conf using the VirtualHost tag. (http://httpd.apache.org/docs/1.3/vhosts/ip-based.html)

While I'm not 100% sure that you can use this in a .htaccess file, I would suggest trying the following:

<VirtualHost www.example.com>
    AddType x-mapp-php5 .php
</VirtualHost>
d3r1v3d
you can. see simultaneous post below. i'm a stackoverflow noob so not sure how to merge the two posts.
nategood
A: 

You can use the VirtualHost directive to accomplish this. I just did the same when I wanted django with mod_python to run only at a subdomain

<VirtualHost *:80>
DocumentRoot /www/docs/path
ServerName www.example.com
....

AddType x-mapp-php5 .php
</VirtualHost>
nategood