.htaccess 301重定向(如果URL包含字符串)

时间:2018-08-21 12:54:15

标签: .htaccess redirect

我正在更改博客文章类别,并希望进行301重定向。因此需要一个基于字符串的.htaccess规则,即它包含的类别/子类别。

这是结构:

https://websitename.com/sample-category/sample-subcategory/post-name/

应该去

https://websitename.com/new-category/new-subcategory/post-name/

https://websitename.com/second-sample-category/second-sample-subcategory/post-name/

应该去

https://websitename.com/brand-new-category/post-name/

我已经尝试过此解决方案

RewriteCond %{REQUEST_URI} /sample-category/sample-subcategory/
RewriteRule .* new-category/new-subcategory/

RewriteCond %{REQUEST_URI} /second-sample-category/second-sample-subcategory/
RewriteRule .* brand-new-subcategory/

但这似乎不起作用。

0 个答案:

没有答案