I would like to have one .htaccess file that can rewrite correctly on both my localhost development environment and on my hosted production site. Right now I have to keep two separate file copies for every site I work on. I would like to be able to synchronize the two sites without blowing away either one of their .htaccess files.
Below is the .htaccess file that I'm using with a little pseudo code in the comments to demonstrate what I want to do.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
## IF the url looks like its from localhost then use this rule
## The incoming url might look like: http://localhost/mysite/about
RewriteRule ^(.*)$ /mysite/index.php/$1 [L]
## Else do this rewrite
## The incoming url might look like: http://www.mysite.com/about
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Here is my server configurations:
Development: xampp on windows
Production: Dreamhost