htaccess 重写规则用于抓取主机名之后的所有内容
我想要一个 htaccess 重写规则来获取主机名之后的所有内容并将其用作参数。例如,我希望 http://example.com/one 由 http://example.com/category.php?cat=one
我认为这应该很简单,但我不太能找到组合。 谢谢
I want an htaccess rewrite rule to grab everything past the host name and use it as an argument. For example, I want http://example.com/one to be handled by http://example.com/category.php?cat=one
I think it should be simple, but I can't quite find the combination.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我想到的:
有人认为有什么方法可以改进它吗?
This is what I came up with:
Anybody see any way to improve it?
尝试这样的操作:
如果您也想传递查询字符串,请务必将
B
标志更改为B,QSA
,但请注意有人可能会传递GET 参数cat
,它将覆盖您在重写中设置的内容。如果您需要的话,有一些解决方法可以解决这种情况,但除此之外,这应该适合您。Try something like this:
If you want to pass the query string along too, be sure to change the
B
flag toB,QSA
, but be aware that someone could then pass the GET argumentcat
, which would override what you set in the rewrite. There are some workarounds to that situation if you need them, but otherwise that should do it for you.