opencart 2.3.0.2 htaccess 301 редирект - PullRequest
0 голосов
/ 20 марта 2019

Я пробовал другие решения, которые я нашел в Интернете, но не тренировался.Мой файл htaccess выглядит так:

Options +FollowSymlinks
Options -Indexes
<FilesMatch "(?i)((\.tpl|\.ini|\.log))">
 Order deny,allow
 Deny from all
 </FilesMatch>

RewriteEngine On
Redirect 301 ^abc https://www.example.com/abc-products


RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteBase /
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Я ожидал example.com/abc перенаправления URL-адресов на example.com/abc-products, но он перенаправляет на example.com/abc-products?_route_=abc

Я также пробовал следующие способы

Redirect 301 ^abc https://www.example.com/abc-products
Redirect 301 ^/abc /abc-products
Redirect 301 /abc /abc-products

Но результат всегда https://www.example.com/abc-products?_route_=abc

Ответы [ 2 ]

1 голос
/ 21 марта 2019

я думаю, вы должны попробовать этот код. 100% работает.

Options +FollowSymlinks
Options -Indexes
<FilesMatch "(?i)((\.tpl|\.ini|\.log))">
 Order deny,allow
 Deny from all
 </FilesMatch>

RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteBase /
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
Redirect 301 / https://www.example.com/abc-products
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Если у вас плохо получается. дай мне знать. Спасибо

1 голос
/ 21 марта 2019

Попробуйте после

RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L] RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]

добавить

 RewriteRule ^abc/(.*)$ /abc-products/$1 [R=301,NC,L]
...