Удалите одну «папку» из URL с перенаправлением 301, оставьте оба URL работающими - PullRequest
1 голос
/ 11 января 2011

URL моего сайта: http://example.com/website/pages/home

Ищу URL: http://example.com/pages/home

Мне нужно, чтобы это был редирект 301, чтобы поисковые системы обновляли мои ссылки.

Это то, что я получил до сих пор:


Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php index.html
RewriteEngine on
\# remove /website/
RedirectMatch  ^(.+)(/website/)(.+)$ $1/$3 [L]
\# remove index.php from URL
RewriteCond $1 !^(index\.php^)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
\# deny access to wget user agent
RewriteCond %{HTTP_USER_AGENT} wget [NC]
RewriteRule (.*) /$1 [L]

Что происходит с этими правилами:

Вставленный URL : http://example.com/website/pages/home

Перенаправленный URL : http://example.com/index.php/pages/home

Ожидаемые результаты : http://example.com/pages/home

Заранее спасибо за помощь.

** решаемый **


Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php index.html

RewriteEngine on

# remove /website/
RedirectMatch  ^(.+)(index.php/website/)(.+)$ $1$3 [R=301,L]

# remove index.php from URL
RewriteCond $1 !^(index\.php^)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

# deny access to wget user agent
RewriteCond %{HTTP_USER_AGENT} wget [NC]
RewriteRule (.*) /$1 [L]

1 Ответ

0 голосов
/ 11 января 2011

RewriteRule ^ (. *) $ Index.Я думаю, что эта строка вставляет index.php в ваш URL.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...