4

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
cmpscabral
  • 183
  • 3
  • 13

1 Answers1

5

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
  • 643,351
  • 109
  • 780
  • 844
  • 1
    This only allows me to set different rewrite rules based on the server, right? what about php flags, etc? – cmpscabral Jan 16 '10 at 19:07
  • @cmpscabral: You can do the same with PHP with `$_SERVER['SERVER_NAME']` and `$_SERVER['DOCUMENT_ROOT']`. – Gumbo Jan 16 '10 at 20:10
  • Gumbo, You already answered my question in another post - http://stackoverflow.com/questions/1599717/conditional-directoryindex-in-htaccess thanks, I'll still mark your answer as correct – cmpscabral Jan 18 '10 at 01:04