URL Re-Write Rule Not Working

此生再无相见时 提交于 2019-12-12 06:09:38

问题


I am trying to rewrite URLs ending like (not only exactly equal to) this:

comments/The-Latest-Out-of-Pakistan/68

into URLs ending in this:

comments/index.php?submissionid=68

Below is what I have in the .htaccess file, but it's not working.

RewriteEngine On
RewriteRule ^comments/([A-Za-z0-9-]+)/([0-9]+)?$ comments/index.php?submissionid=$2 [NC,L]

Any idea why it's not working?

Thanks in advance,

John


回答1:


I think the only issue is that you've not escaped the hyphen in the character class [A-Za-z0-9-]+, try replacing it with this [A-Za-z0-9\-]+ and see if that works. If not, we can work from there.




回答2:


I tested it and this one works:

RewriteEngine On
RewriteRule ^comments/([a-zA-Z0-9-]+)/([0-9]+)?$ comments/index.php?id=$2 [NC,L]


来源:https://stackoverflow.com/questions/3118690/url-re-write-rule-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!