问题
I use the following rule
RewriteRule ^([\w]+)/?([\w]+)? index.php?action=$1
for rewriting
www.mysite.com/123
to
www.mysite.com/index.php?action=123
This needs to remain like this, but there are cases where I also need to rewrite
www.mysite.com/123/abc
to
www.mysite.com/index.php?action=123&example=abc
How can I achieve this? Thanks!
回答1:
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?action=$1&example=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ index.php?action=$1 [L,QSA]
来源:https://stackoverflow.com/questions/16753370/htaccess-rewrite-rule-for-more-than-one-parameter