2013-11-29 3 views
0

из-за требований SEO, которые я должен охватить все эти типы запросов:Htaccess перенаправить если multislashes в конце URL

1 - http://example.com 
2 - http://example.com//// 
3 - http://example.com////about 
4 - http://example.com////about//// 
5 - http://example.com////about////info 
6 - http://example.com////about////info//// 

и вперед пользователей с 301 перенаправления

1 - http://example.com/ 
2 - http://example.com/ 
3 - http://example.com/about/ 
4 - http://example.com/about/ 
5 - http://example.com/about/info/ 
6 - http://example.com/about/info/ 

Для первого случай я использую

RewriteEngine on 
Options +FollowSymlinks 
RewriteCond %{REQUEST_URI} !(.*)/$ 
RewriteRule ^(.*[^/])$ $1/ [L,R=301] 

Но не understant как писать правила для других случаев

ответ

1

Попробуйте эти правила:

RewriteEngine on 
RewriteBase/

# add trailing slash if missing 
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=302,NC,NE] 

# remove multiple slashes 
RewriteCond %{THE_REQUEST} \s/+(.*?)//(.*?)\s [NC] 
RewriteRule^%1/%2 [L,R=302,NC,NE] 
0
# Remove multiple slashes anywhere in URL 
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ 
RewriteRule . %1/%2 [R=301,L] 
+0

Но почему вы получите URL-адреса, как это? Вышла ли из-под контроля CMS? – Reeno

+0

'//////// about/info' остается неизменным с этим – anubhava

Смежные вопросы