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.
我正在开发另一个开发人员几年前构建的自定义CMS。我需要更改URL以从查询字符串中清除基于段的URL。我可以为.htaccess文件中的所有页面添加规则,这将是一个痛苦,因为这是很多页面。另外,当添加新页面时,显然我不会在那里等待快速添加重写规则。
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?
如何设置它以便自动添加它自己的重写规则。像Drupal和Wordpress中的模块和插件一样吗?
Thanks!
1 个解决方案
#1
0
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.
http://www.generateit.net/mod-rewrite/并将它们添加到根文件夹中的.htaccess。
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.
然后通过并更改代码中的链接,交换查询字符串部分,?q = etc,无论您选择哪个分隔符, - 或/。瞧,现在应该可以了。
Hope this helps someone else...
希望这有助于其他人......
#1
0
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.
http://www.generateit.net/mod-rewrite/并将它们添加到根文件夹中的.htaccess。
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.
然后通过并更改代码中的链接,交换查询字符串部分,?q = etc,无论您选择哪个分隔符, - 或/。瞧,现在应该可以了。
Hope this helps someone else...
希望这有助于其他人......