Mod 重写 - 如何在 .htaccess 中手动重写所有 URL?
我正在开发另一个开发人员几年前构建的自定义 CMS。我需要更改 url 以从查询字符串中清除基于段的 url。我可以只为 .htaccess 文件中的所有页面添加规则,这会很痛苦,因为页面很多。另外,当添加新页面时,显然我不会在那里等待快速添加重写规则。
我如何设置它以便它自动添加它自己的重写规则。像 Drupal 和 Wordpress 中的模块和插件一样吗?
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,请按照我的评论进行操作:
手动(如果您很生气)或使用这个很棒的工具获取网址的重写规则:
http://www.generateit.net/mod-rewrite/ 并将它们添加到根文件夹中的 .htaccess 中。
然后检查并更改代码中的链接,将查询字符串部分 ?q= 等替换为您选择的分隔符 - 或 /。瞧,它现在应该可以工作了。
希望这对其他人有帮助......
Ok so following on from my comment:
Get the rewrite rules for your urls either by hand (if you're mad) or using this great tool:
http://www.generateit.net/mod-rewrite/ and add them to .htaccess in your root folder.
Then go through and change the links in your code swapping out the query string parts, ?q= etc, for whichever delimiter you chose, - or /. Et voila, it should now work.
Hope this helps someone else...