2017-07-03 78 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]