Mod rewrite won't work with slashes in rewrite rules
Stack,
I have been pulling my hair out today and yesterday trying to figure out the issue I have with mod_rewrite.
I'm running an ubuntu lamp server and I've gotten mod_rewrite turned o开发者_如何学编程n and working for simple rewrites such as:
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
But whenever I try to rewrite urls to turn my dynamic urls into cleaner static looking urls IE:
random/5000/
to random.php?id=5000
mod rewrite fails to rewrite the variable. However if I create this following rule it works:
random5000.html
to random.php?id=5000
It looks like mod rewrite is simply not accepting slashes in my rewrite rules.
Here is what my rewrite rule looks like.
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^random/([0-9]+)$ random.php?id=$1
I haven't tested this but maybe your RewriteRule
should look like this:
RewriteRule ^random/([0-9]+)/$ random.php?id=$1
(missing /
at the end). Please add comment if it fails.
精彩评论