mod_rewrite 和explode("/", $_SERVER['REQUEST_URI'])
如果我的路由系统中已经有explode("/", $_SERVER['REQUEST_URI']),为什么我需要mod_rewrite 和其他apache url 重写设置?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您没有 mod_rewrite 和 .htaccess 文件来指定如何处理像
domain.com/foo/bar
这样的 url 时,服务器会搜索文件夹foo
,然后文件夹bar
查找索引文件以显示给用户。如果您需要在脚本中处理它,您需要首先将用户重定向到您的基本脚本,然后在查询字符串上使用explode,然后继续下一步。这就是 mod_rewrite 和 .htaccess 发挥作用的地方。
When you do not have mod_rewrite and the .htaccess file to specify what to do with an url like
domain.com/foo/bar
the server searches for the folderfoo
and then the folderbar
to look for the index file to show the user.If you need it to be handled within your script, you need to first redirect the user to your base script then use explode on your query string and then proceed further. This is where mod_rewrite and .htaccess come into play.
当 URL 结构与目录结构不同时,要拥有干净的 URL。
几点:
有关更多信息,请阅读此处: URL 重写指南
To have Clean URLs, When URL structure is not same as the directory structure.
Some points:
For more read here: URL Rewriting Guide