mod将domain后面的所有内容重写为get
如果还没有get,如何将域名后面的所有内容重写为get?
例如: example.com/blah/blah.blah
将变为 example.com/?blah/blah.blah
基本上我想做的就是添加一个 ?在第一个正斜杠之后(如果还没有的话)。
谢谢!
How can I rewrite everything after the domain name into get if it is not already get?
For example : example.com/blah/blah.blah
will become example.com/?blah/blah.blah
basically all I want to do is add a ? after the first forward slash if there isnt one already.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
但这个解决方案有一些问题,@anubhava 的更好;-)
But this solution has some issues, @anubhava's is better ;-)
非常简单地使用变量
%{REQUEST_URI}
作为查询参数:Quite simply use variable
%{REQUEST_URI}
as a query parameter:另一种技术是使用 $_GLOBALS['PATH_INFO'] 变量,它将为您提供脚本名称后的其余路径,因此对于:
PATH_INFO 将设置为“/james/fred/blogs.csv”,您仍然会可以单独使用 GET/POST 变量作为修饰符。这可能非常有用,例如,如果您想创建一个 .csv 文件并让它在远程浏览器客户端上显示为“blogs.csv”。
Another technique is to use the $_GLOBALS['PATH_INFO'] variable which will give you the rest of the path after the script name, so for:
PATH_INFO would be set to "/james/fred/blogs.csv" and you would still have the possibility of using GET/POST variables separately as modifiers. This can be quite useful, for example if you want to create a .csv file and have it appear to the remote browser client as if it were named "blogs.csv".