重写除一个文件夹以外的所有请求

时间:2013-11-11 17:47:44

标签: php regex apache .htaccess mod-rewrite

我是htaccess的新手,但我想将所有来到我的网络服务器的网址重写为index.php?params = $ 1,资源文件夹除外。我尝试过这样的事情:

Options +FollowSymlinks
RewriteEngine on
RewriteRule !^assets($|/) index.php?params=$1 [NC]

但是,当我使用var_dump作为params变量时,它会返回一个空变量。

非常感谢

1 个答案:

答案 0 :(得分:1)

这应该有效:

RewriteEngine on

RewriteCond %{REQUEST_URI} !^/(assets/|index\.php) [NC]
RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]