【发布时间】:2017-12-06 23:48:57
【问题描述】:
我有一个任务 - 所有带有斜杠的 somestuff.html/ 页面都必须重定向到 somestuff.html,所有其他没有斜杠的页面必须重定向以添加斜杠(例如 /mypage 必须重定向到 /mypage/)。我已经完成了任务,但现在 /administrator/ 页面返回 404 页面。我试图排除 /administrator/ 页面,但它不起作用:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#this part breaks the admin panel entry
RewriteRule ^([^.]+).html/ http://somedomain.com/$1\.html [R=301,L]
RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif)$
#trying to exclude administrator page
RewriteCond %{REQUEST_URI} !^/administrator/
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
#end of part that breaks the admin panel entry
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
谁能告诉我我做错了什么,或者可以提供一些不同的解决方案来完成重定向。谢谢。
【问题讨论】: