mod_rewrite confusion
I have a few rewritten urls pointing to the original dynamic urls like so:
http://mysite.com/profile/edit/ => http://mysite.com/index.php?action=profile&sa=edit
Here's the rewriterule in the htaccess:
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?action=$1&sa=$2 [L]
^ So that works just fine.
Now I also have the following url:
http://mysite.com/search/editorial开发者_开发技巧s/ => http://mysite.com/index.php?action=search&category=editorials
The rewrite which follows the previous rewrite rule posted above:
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?action=$1&category=$2 [L]
^ This does not work. I checked the $_SERVER array and this is what's being redirected to the query string:
action=search&sa=editorials
I've been at this for a day so far, I've tried various tutorials but with no luck. How do I get this to work?
Any help appreciated. Thank you.
The two rewrites are conflicting with each other. You need to create some type of distinction between the two of them
RewriteRule ^account/(.)/([^/])/$ /index.php?action=$1&sa=$2 [L]
RewriteRule ^([^/])/([^/])/$ /index.php?action=$1&category=$2 [L]
or make the parameters consistent and use a single rewrite:
RewriteRule ^([^/])/([^/])/$ /index.php?action=$1&parm1=$2 [L]
精彩评论