我想有一个.htaccess文件,可以在我的本地主机开发环境和托管的生产站点上正确重写。现在我必须为每个我工作的网站保留两份单独的文件副本。我希望能够同步这两个网站,而不会吹掉其中一个.htaccess文件。如何编写一个基于请求url进行不同重写的.htaccess?
下面是.htaccess文件,我在注释中使用了一些伪代码来演示我想要做什么。
<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>
这里是我的服务器配置:
发展:XAMPP在Windows
生产:Dreamhost的
然而,这是一个好主意,我喜欢来开发和调试在我本地机器然后上传更改。 – 2009-10-08 20:04:31