我怎么能通过htaccess重定向

时间:2010-09-02 08:10:03

标签: apache .htaccess url-rewriting

我想重定向

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

怎么做?

1 个答案:

答案 0 :(得分:0)

以下内容应该足够了:

<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>