开发者

URL Re-Write Rule Not Working

开发者 https://www.devze.com 2023-01-04 14:30 出处:网络
I am trying to rewrite URLs ending like (not only exactly equal to) this: comment开发者_开发技巧s/The-Latest-Out-of-Pakistan/68

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

comment开发者_开发技巧s/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


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.


I tested it and this one works:

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

精彩评论

暂无评论...
验证码 换一张
取 消