![](/img/trans.png)
[英].htaccess - Recursively mapping slashes to underscores (internal redirect)
[英].htaccess redirect link with less then 4 slashes
我使用正则表达式没有问题,但是我不知道如何编写.htaccess规则,我能否获得如何根据给定规则重定向页面:
OK /page/product/type/id
301 /page/product/type => /otherPage/product/type
301 /page/product => /otherPage/product
301 /page => /otherPage
301 /otherPage/product/type/id => /page/product/type/id
您可以在DOCUMENT_ROOT/.htaccess
文件中使用以下代码:
RewriteEngine On
RewriteRule ^page/([^/]+/[^/]+/?)$ /otherPage/$1 [L,NC,R=302]
RewriteRule ^page/([^/]+/?)$ /otherPage/$1 [L,NC,R=302]
RewriteRule ^page/?$ /otherPage [L,NC,R=302]
RewriteRule ^otherPage/([^/]+/[^/]+/[^/]+/?)$ /page/$1 [L,NC,R=302]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.