我正在更改博客文章类别,并希望进行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/
但这似乎不起作用。