salex Posted September 5, 2014 Share Posted September 5, 2014 Доброго дня всем. Дурная голова (рукам) ногам покоя не дает...Решил поменять немножко вид ссылок. Было:сайт/topic/104-tema/ стало /topic104/сайт/forum/12-forum/ стало /forum12/Так увлекся сменой урлов, что забыл про ошибку 404 в выдаче. Как правильно организовать 301 редирект? Очень надеюсь на вашу помощь. Спасибо. Link to comment Share on other sites More sharing options...
siv1987 Posted September 5, 2014 Share Posted September 5, 2014 Добавить после RewriteEngine On RewriteRule ^(topic|forum)/(\d+)-[^/]+/(.*) /$1$2/$3 [R=301,L] 1 Link to comment Share on other sites More sharing options...
salex Posted September 5, 2014 Author Share Posted September 5, 2014 (edited) 500 ошибка встает, если добавлю после RewriteEngine On<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://alcogolik.net/ [R=301,L] RewriteRule ^home\.php$ http://alcogolik.net/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(jpeg|jpg|gif|png)$ /public/404.php [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Все. Заработало. Спасибо огромное! Edited September 5, 2014 by salex Link to comment Share on other sites More sharing options...
siv1987 Posted September 5, 2014 Share Posted September 5, 2014 Пардон, пропустил имя директивы. В данном случае можно даже добавить после RewriteBase 1 Link to comment Share on other sites More sharing options...
salex Posted September 5, 2014 Author Share Posted September 5, 2014 топики заработали, а форумы нет. З.Ы. Посмотрел, что еще в индексе несколько есть старых ссылок в виде сайт/f12/ а сейчас /forum12/ Link to comment Share on other sites More sharing options...
siv1987 Posted September 5, 2014 Share Posted September 5, 2014 Почистите кеш браузера. Если работают темы то должны работать и форумы. Собственно я вижу что редирект у форумов есть. Link to comment Share on other sites More sharing options...
salex Posted September 5, 2014 Author Share Posted September 5, 2014 Да. Со старых редирект есть. Это просто гугл уж такой быстрый, что пока я правил ЧПУ и напортачил вместо /topic/ - оставил /t/, а /forum/ - /f/ думал так еще уменьшить длину урл. Назад вернул, а гугл уже проиндексировал. И сейчас в индексе у гугласайт/t104/сайт/f12/В яндексе все нормально. Он даже и не узнал, что я что-то менял)) Там редирект отрабатывает сейчас на все 100%. Link to comment Share on other sites More sharing options...
siv1987 Posted September 5, 2014 Share Posted September 5, 2014 Там же ниже добавить RewriteRule ^t(\d+)/(.*) /topic$1/$2 [R=301,L]RewriteRule ^f(\d+)/(.*) /forum$1/$2 [R=301,L] 1 Link to comment Share on other sites More sharing options...
salex Posted September 5, 2014 Author Share Posted September 5, 2014 Все. Все отлично теперь. Большое спасибо за помощь! Link to comment Share on other sites More sharing options...
salex Posted April 24, 2016 Author Share Posted April 24, 2016 Еще один вопрос по редиректу, если можно)Как правильно перенаправить к примеру с topic/page12/ на topic/?page=12 Link to comment Share on other sites More sharing options...
siv1987 Posted April 24, 2016 Share Posted April 24, 2016 RewriteRule ^topic/page(\d+)/ /topic/?page=$1 1 Link to comment Share on other sites More sharing options...
salex Posted April 24, 2016 Author Share Posted April 24, 2016 (edited) что-то не выходит..<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteRule ^topic/page(\d+)/ /topic/?page=$1 [R=301,L] RewriteRule ^(topic|forum)/(\d+)-[^/]+/(.*) /$1$2/$3 [R=301,L] RewriteRule ^t(\d+)/(.*) /topic$1/$2 [R=301,L] RewriteRule ^f(\d+)/(.*) /forum$1/$2 [R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(jpeg|jpg|gif|png)$ /public/404.php [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Edited April 24, 2016 by salex Link to comment Share on other sites More sharing options...
salex Posted April 24, 2016 Author Share Posted April 24, 2016 (edited) Не правильно я спросил... Если topic12/page12/Так не правильно?RewriteRule ^topic(\d+)/page(\d+)/ /topic$1/?page=$1 [R=301,L] Edited April 24, 2016 by salex Link to comment Share on other sites More sharing options...
siv1987 Posted April 24, 2016 Share Posted April 24, 2016 RewriteRule ^topic(\d+)/page(\d+)/ /topic$1/?page=$2 [R=301,L] 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now