htaccess 重定向某些网址的问题
我有一堆遵循这种格式的 .htaccess 规则
RewriteCond %{HTTP_HOST} ^www.lazygamer\.co.za$ [NC]
RewriteRule ^(.*)$ http://www.lazygamer.net/$1 [R=301,L]
现在我需要放入一个新规则以在我的 URL 中包含一个类别字符串并获得此代码
RewriteRule ^/([^/]+)/$ /category/$1/ [R]
但由于某种原因它没有被解雇,有人可以告诉我如何更改上面的字符串以进一步匹配规则..所以我在执行规则之前检查某些条件?
仅当网址格式为 http://www.lazygamer.net/ 时,我才需要触发此规则post-name/ 而不是当 url 的格式为 http://www.lazygamer.net/category/post-name/
I have a bunch of .htaccess rules that follow this format
RewriteCond %{HTTP_HOST} ^www.lazygamer\.co.za$ [NC]
RewriteRule ^(.*)$ http://www.lazygamer.net/$1 [R=301,L]
Now I need to put in a new rule to include a category string in my URL and was given this code
RewriteRule ^/([^/]+)/$ /category/$1/ [R]
But it's not being fired for some reason, can someone please show me how to change the above string to match the rule further up.. so I check for some condition before executing the rule?
I only need this rule to fire if the url is in the format http://www.lazygamer.net/post-name/ and not when the url is in the format http://www.lazygamer.net/category/post-name/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的 htaccess 文件现在看起来像这样并解决了问题
倒数第二行忽略了让我彻夜难眠的根文件夹......
My htaccess file now looks like this and solves the problem
The second last line ignore the root folder which kept me up all night...