opencart 2.3.0.2 htaccess 301重定向

问题描述 投票:0回答:2

我尝试了我在网上找到的其他解决方案,但没有锻炼。我的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

php .htaccess opencart url-redirection
2个回答
1
投票

试试看

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]

1
投票

我想你应该尝试这个代码。 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]

如果你工作不好。告诉我一声。谢谢

© www.soinside.com 2019 - 2024. All rights reserved.