.htaccess rewrite rule for two GET variables on index.php?

我与影子孤独终老i 提交于 2020-01-06 01:08:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!