我正在尝试重定向
https://www.example.com/category/以及https://category.example.com的所有子类别和内容
所以最后我得到了
https://category.example.com/subcategory/content=xyz;param=1
重定向
https://www.example.com/category/subcategory/content=xyz;param=1
我在这里尝试了很多来自其他线程的建议,但只得到了
https://www.example.com/category/subcategory/content=xyz;param=1
https://category.example.com/
和
https://www.example.com/category/subcategory/content=xyz;param=1
https://category.example.com/category/subcategory/content=xyz;param=1
工作。我认为这是我的正则表达式,但我不确定。我的配置是
RewriteEngine On
RewriteLog /var/log/vgn_rewrite.log
RewriteLogLevel 5
RewriteCond %{HTTP_HOST} !category.example.com$ [NC] [OR]
RewriteCond %{REQUEST_URI} ^(.*)/category/(.*)$
RewriteRule ^/(.*)$ https://category.example.com$1 [R=301,L]
你可以试试这个:
RewriteEngine On
RewriteRule ^category/(.*)/(.*)$ https://category.yourwebsite.com/$1/$2 [R=301,L]
找到了解决方案。我想我所有的尝试都变得复杂了。
RewriteEngine On
RewriteCond %{HTTP_HOST} !category.example.com$ [NC]
RewriteRule ^/category(.*)$ https://category.example.com$1 [QSA,R=301,L]
终于来了!谢谢你的帮助!