2017-07-03 55 views
0

我有一个任务 - 所有somestuff.html /页尾斜杠必须重定向到somestuff.html和所有其他页面没有结尾斜杠必须重定向添加尾部斜杠(例如/ mypage必须重定向到/ mypage /)。我已完成任务,但现在/管理员/页面返回404页面。我试图排除/管理者/页,但它不工作:htaccess重定向影响Joomla的管理员页面

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] 

谁能告诉我什么,我做错了或可能提供一些不同的解决方案,以acocmplish重定向。谢谢。

回答

0

实测值的溶液:

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 

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^.]+).html/ http://logosstudy.ru/$1\.html [R=301,L] 
RewriteCond %{REQUEST_URI} !^/administrator/ 
RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif)$ 
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301] 
RewriteCond %{REQUEST_URI} !^/administrator/ 
RewriteCond %{REQUEST_FILENAME} !-d 

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]