【发布时间】:2014-08-20 16:20:35
【问题描述】:
我有一个似乎无法调试的问题。我尝试了很多解决方案,但都没有运气。
当我使用 subfolder/index.php 访问 URL 时,我会被重定向回根页面。如果我访问该子文件夹中的另一个页面,它工作正常。我不确定是什么导致我的代码出现这种情况。这是我所拥有的。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.domain\.com
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)index$ $1 [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
有什么建议吗?谢谢!
【问题讨论】:
标签: php apache .htaccess redirect subdirectory