我有一个加载www.example.com默认index.php page. 我也有一个login.php,我已经为它设置了这个重写规则。一切正常,但是当我尝试访问它时,www.example.com它会将我重定向到login.php.我想在不影响默认页面的情况下保留规则。请看下面。如果有人有任何想法那就太好了。# ensure permalink when url rewriting was enabled (login.php?r=content/perma&id=6 => /content/perma/?id=6RewriteCond %{QUERY_STRING} ^r=content(/|%2)perma&id=([0-9]*)$RewriteRule ^login\.php$ %{REQUEST_URI}/content/perma/?id=%2 [R=302,L]RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$RewriteRule ^(.*) - [E=BASE:%1]# Sets the HTTP_AUTHORIZATION header removed by apacheRewriteCond %{HTTP:Authorization} .RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]RewriteCond %{REQUEST_FILENAME} -fRewriteRule .? - [L]RewriteRule .? %{ENV:BASE}/login.php [L]
1 回答
慕码人8056858
TA贡献1803条经验 获得超6个赞
您可以在站点根目录 .htaccess 中使用此代码:
# ensure permalink when url rewriting was enabled
# (login.php?r=content/perma&id=6 => /content/perma/?id=6
RewriteEngine On
RewriteCond %{QUERY_STRING} ^r=content(/|%2)perma&id=([0-9]*)$
RewriteRule ^login\.php$ %{REQUEST_URI}/content/perma/?id=%2 [R=302,L]
# Sets the HTTP_AUTHORIZATION header removed by apache
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . login.php [L]
- 1 回答
- 0 关注
- 93 浏览
添加回答
举报
0/150
提交
取消