Mod 重写 - 如何在 .htaccess 中手动重写所有 URL?

发布于 2024-09-27 03:37:21 字数 209 浏览 1 评论 0 原文

我正在开发另一个开发人员几年前构建的自定义 CMS。我需要更改 url 以从查询字符串中清除基于段的 url。我可以只为 .htaccess 文件中的所有页面添加规则,这会很痛苦,因为页面很多。另外,当添加新页面时,显然我不会在那里等待快速添加重写规则。

我如何设置它以便它自动添加它自己的重写规则。像 Drupal 和 Wordpress 中的模块和插件一样吗?

谢谢!

I'm working on a custom CMS that another developer built a few years ago. I need to change the urls to clean segment based urls from query strings. I could just add the rules for all the pages in the .htaccess file, which would be a pain as that's a lot of pages. Plus when a new page is added, obviously I won't be there waiting to quickly add a rewrite rule.

How do I set this up so it automatically adds it's own rewrite rules. Like the modules and plugins in Drupal and Wordpress do?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生生漫 2024-10-04 03:37:21

好的,请按照我的评论进行操作:

手动(如果您很生气)或使用这个很棒的工具获取网址的重写规则:

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文