@ozonpromo

Как убрать метки в url после 301 редиректа?

Есть файл .htaccess
DirectoryIndex index.html index.shtml index.pl index.cgi index.php

# SEO URL Settings
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]
RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]

# HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>


Делаю 301 редирект с одной страницы на другую
Redirect 301 /oldpage https://site/newpage
После редиректа на новую страницу в url появляются метки ?path=
https://site/uslugi/newpage?path=oldpage

Перепробовал уже все, ничего не помогает.
  • Вопрос задан
  • 299 просмотров
Пригласить эксперта
Ответы на вопрос 1
@dodo512
Проблема возникает при одновременной работе mod_alias и mod_rewrite
Redirect 301 /oldpage https://site/newpage

RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]


Нужно делать редирект средствами mod_rewrite
RewriteRule ^oldpage$ https://site/newpage [R=301,L]


DirectoryIndex index.html index.shtml index.pl index.cgi index.php

RewriteEngine On
RewriteBase /

# HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]

RewriteRule ^oldpage$ https://site.ru/newpage [R=301,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы