how can i redirect via htaccess

泄露秘密 提交于 2020-01-30 11:16:19

问题


i want to redirect

http://abc.com/a to /mypage.php?par1=a and 
http://abc.com/a/b to /mypage.php?par1=a&par2=b

how can it be done?


回答1:


The following should be enough:

<IfModule mod_rewrite.c>
  RewriteBase /

  #so i doesn't match a real file/folder
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^(\w+)$ mypage.php?par1=$1
  RewriteRule ^(\w+)/(\w+)$ mypage.php?par1=$1&par2=$2
</IfModule>


来源:https://stackoverflow.com/questions/3624896/how-can-i-redirect-via-htaccess

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