使用GET参数重写URL

时间:2019-03-24 11:56:54

标签: .htaccess url mod-rewrite

我的目标是将以下页面从/重定向至:

/ -> /util/master.php?view=home # default site
/contact -> /util/master.php?view=contact # site
/contact?a=1&b=2 -> /util/master.php?view=contact&a=1&b=2 # site with params
/res/style.css -> /res/style.css # don't redirect files

我当前的重写脚本如下,但它总是会给我500错误。

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^(.*)$ util/master.php?view=$1&%{QUERY_STRING} [NC,L]

(如here所示)

编辑:而且,它应该能够使用“子页面”:

/contact/form?a=1&b=2 -> /util/master.php?view=contact/form&a=1&b=2 # sub page with params

0 个答案:

没有答案