views:

393

answers:

1

Is it possible to write some conditional "if" statements in htaccess based on the server name/path?

I know I can use <IfModule> but that doesn't solve the problem when the development and production server are identical.

thanks

+1  A: 

You can test the value of SERVER_NAME or DOCUMENT_ROOT:

RewriteCond %{SERVER_NAME} =foo
RewriteRule …
RewriteCond %{DOCUMENT_ROOT} =/path/to/document/root/
RewriteRule …
Gumbo
This only allows me to set different rewrite rules based on the server, right? what about php flags, etc?
cmpscabral
@cmpscabral: You can do the same with PHP with `$_SERVER['SERVER_NAME']` and `$_SERVER['DOCUMENT_ROOT']`.
Gumbo
Gumbo,You already answered my question in another post - http://stackoverflow.com/questions/1599717/conditional-directoryindex-in-htaccessthanks, I'll still mark your answer as correct
cmpscabral