如何使用参数重定向页面?
http://stackoverflow.com/questions/abcd.html&p=1
http://stackoverflow.com/answers/wxyz.html&p=5
http://stackoverflow.com/database/mnop.html&p=167
http://stackoverflow.com/questions/abcd.html?p=1
http://stackoverflow.com/answers/wxyz.html?p=5
http://stackoverflow.com/database/mnop.html?p=167
http://stackoverflow.com/order/anything.html?mode=new
http://stackoverflow.com/checkout/something.html?mode=old
我想将所有类似这样的网址重定向到:
http://stackoverflow.com/questions/abcd.html
http://stackoverflow.com/answers/wxyz.html
http://stackoverflow.com/database/mnop.html
http://stackoverflow.com/order/anything.html
http://stackoverflow.com/checkout/something.html
请suugest me。
http://stackoverflow.com/questions/abcd.html&p=1
http://stackoverflow.com/answers/wxyz.html&p=5
http://stackoverflow.com/database/mnop.html&p=167
http://stackoverflow.com/questions/abcd.html?p=1
http://stackoverflow.com/answers/wxyz.html?p=5
http://stackoverflow.com/database/mnop.html?p=167
http://stackoverflow.com/order/anything.html?mode=new
http://stackoverflow.com/checkout/something.html?mode=old
I want to redirect all urls like these to:
http://stackoverflow.com/questions/abcd.html
http://stackoverflow.com/answers/wxyz.html
http://stackoverflow.com/database/mnop.html
http://stackoverflow.com/order/anything.html
http://stackoverflow.com/checkout/something.html
Please suugest me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
那么您想删除所有 URL 参数吗?鉴于这个问题被标记为 .htaccess,我假设这就是您想要用来进行重定向的内容。
这条规则基本上是说,给我所有格式为
*?*
的内容,然后忽略问号后面出现的所有内容。You want to remove all URL parameters then? Given that this question is tagged to .htaccess, I assume that's what you want to use to do your redirect.
This rule basically says, given me everything that is in the format
*?*
, and then just ignore all the content that occurs after the question mark.假设您正在谈论一个 Web 服务器,并且该服务器是 apache,请查看 mod_rewrite。
http://www.elated.com/articles/mod-绝对初学者重写教程/
Assuming you're talking about a web server, and that server is apache, take a look at mod_rewrite.
http://www.elated.com/articles/mod-rewrite-tutorial-for-absolute-beginners/
试试这个代码
但在前端网络服务器(nginx 等)中执行此操作的最佳方法
Try this code
But the best way doing this in frontend webserver (nginx e.t.c)