我尝试了一些解决方法,但是似乎找不到有效的解决方案。 当我尝试为URL创建301重定向时,重定向似乎有效,但在目标URL的末尾附加了“位置”字,该URL在要重定向的URL中引用。例如:
Redirect 301 /web-design/ecommerce/london/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
结果:
https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/london/
文件中还有其他重定向,但是我也尝试删除所有重定向,以防它们产生影响。
完整的htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect 301 /web-design/ecommerce/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
Redirect 301 /web-design/ecommerce/reading/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
Redirect 301 /web-design/ecommerce/marlow/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
Redirect 301 /web-design/ecommerce/oxford/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
Redirect 301 /web-design/ecommerce/newbury/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
Redirect 301 /web-design/ecommerce/bracknell/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
Redirect 301 /web-design/ecommerce/wokingham/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
Redirect 301 /web-design/ecommerce/london/ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/
答案 0 :(得分:0)
每个使用mod_rewrite
的规则都像这样:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^web-design/ecommerce/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteRule ^web-design/ecommerce/reading/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteRule ^web-design/ecommerce/marlow/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteRule ^web-design/ecommerce/oxford/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteRule ^web-design/ecommerce/newbury/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteRule ^web-design/ecommerce/bracknell/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteRule ^web-design/ecommerce/wokingham/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteRule ^web-design/ecommerce/london/?$ https://www.orangegrovedesigns.co.uk/web-services/web-design/ecommerce-web-design/ [L,NC,R=301]
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
在测试此更改之前,请确保完全清除浏览器缓存。