【发布时间】:2013-09-15 13:14:42
【问题描述】:
我为301 redirect编写了这段代码
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
如果我以http://mysite.com/index.php 访问我的网站,它会很好地工作,它会将我重定向到http://mysite.com
但是在我的localhost 上,如果我尝试以localhost/mysite/index.php 访问index.php,它会将我重定向到localhost。
我该如何解决这个问题?上面写的代码对吗?
【问题讨论】:
-
在您的本地主机上,您需要在这些行上方添加
RewriteBase /mysite/,因为该站点不在服务器的根目录中
标签: php apache .htaccess redirect mod-rewrite