[英]301 redirect for old URL's with regular expression through .htaccess
I am trying to implement 301 redirect from old web-site to new web-site url structure (custom CMS).我正在尝试实现从旧网站到新网站 url 结构(自定义 CMS)的 301 重定向。 In my example I am trying to redirect this structure:
在我的示例中,我试图重定向此结构:
/shop/my-product-name
to至
/fr/my-product-name
This is what I have, but the web-site shows me empty page:这就是我所拥有的,但该网站向我显示了空白页面:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteRule ^index\.html$ / [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^/shop/(.*)$ /fr/$1 [R=301,L]
RewriteRule ^(en|fr|de|es|it)/?$ index.php?lang=$1 [QSA,L]
RewriteRule ^(en|fr|de|es|it)/news/?$ index.php?lang=$1§ion=blogposts [QSA,L]
it seems to me that the code is absolutely fine.在我看来,代码绝对没问题。 What am I doing wrong?
我究竟做错了什么? Thanks
谢谢
It should be它应该是
RewriteRule ^shop/(.*)?$ fr/$2 [R=301,L]
as it happens the problem was with leading slash in the beginning碰巧问题出在开头的斜杠
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.