问题
I'm trying to do a rewrite but I couldn't find it or do it myself.
I'm trying to convert
http://www.homepage.com/variable1/variable2
to http://www.homepage.com/index.php?var1=variable1&var2=variable2
or http://www.homepage.com/?var1=variable1&var2=variable2
I have tried
RewriteRule ^/(.*)/(.*)$ ?var1=$1&var2=$2 [NC,L]
RewriteRule ^(.*)/(.*)$ ?var1=$1&var2=$2 [NC,L]
RewriteRule ^/(.*)/(.*)$ index.php?var1=$1&var2=$2 [NC,L]
RewriteRule ^(.*)/(.*)$ index.php?var1=$1&var2=$2 [NC,L]
none of these worked. What am I doing wrong? Thanks !
回答1:
This worked for me:
RewriteRule ^(.*)/(.*)$ /index.php?var1=$1&var2=$2 [NC,L]
You didn't put / before index.php.
来源:https://stackoverflow.com/questions/17630676/htaccess-rewrite-rule-for-two-get-variables-on-index-php