how can i redirect via htaccess

前端 未结 1 1771
醉话见心
醉话见心 2021-01-28 14:41

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条回答
  •  北海茫月
    2021-01-28 15:36

    The following should be enough:

    
      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
    
    

    0 讨论(0)
提交回复
热议问题