.htaccess将特定子目录重定向到querystring参数

时间:2012-12-24 05:35:23

标签: apache .htaccess redirect rewrite

需要.htaccess执行以下操作,我无法让它工作:

将以/recordings/结尾的所有网址重定向到?recordings

例如:

www.mysite.com/example-product-one/recordings/

变为

www.mysite.com/example-product-one/?recordings

或者,

www.mysite.com/products/category/three/recordings 

变为

www.mysite.com/products/category/three/?recordings

连连呢?谢谢。

2 个答案:

答案 0 :(得分:0)

你可以试试这个:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(.*)/([^/]+)/?$
RewriteRule .*   %1/?%2     [L,R=301]

答案 1 :(得分:-2)

感谢您指出我正确的方向......这就是最终的工作:

RewriteEngine On
RewriteBase /
RewriteRule /recordings/$ %{REQUEST_URI}../?recordings [L,R=301]