使用.htaccess使用静态查询字符串重写URL

时间:2013-10-29 16:36:31

标签: apache .htaccess

我想将一个url重写为静态查询:

example.com/register => example.com/login.php?page=register

我正在使用它:

RewriteRule ^register login.php?page=register [NC,L]

2 个答案:

答案 0 :(得分:2)

像这样使用:

RewriteEngine On

RewriteRule ^(register)/?$ /login.php?page=$1 [NC,L,QSA]

答案 1 :(得分:0)

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(register)$ login.php?page=$1 [NC,QSA,L]

或:

RewriteRule ^register$ login.php?page=register [NC,QSA,L]