问题
Using the answer I received from rcs20 in my previous post when I add this entry to my .htaccess file I see the error 404 Not Found:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^member\-([0-9]+)\-([^/])\.htm(l)?$ view_profile.php?id=$1 [NC,L]
The URL I'm passing it is:
mysite/member-8222-jane.html
Any idea why this might be happening. My old rewrite rule works fine:
RewriteRule view_profile=(.*)$ view_profile.php?id=$1
回答1:
found it:
The +
sign needs to be added to [^/]
=> ([^/]+)
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^member\-([0-9]+)\-([^/]+)\.htm(l)?$ view_profile.php?id=$1 [NC,L]
You can also add the extra chars jane
in member-8222-jaane.html
by using the $2 like:
RewriteRule ^member\-([0-9]+)\-([^/]+)\.htm(l)?$ view_profile.php?id=$1&extra=$2 [NC,L]
来源:https://stackoverflow.com/questions/9134399/rewrite-rule-for-apache-not-finding-url