htaccess禁止我使用完整路径

时间:2015-06-29 18:56:57

标签: regex .htaccess mod-rewrite rewrite favicon

所以我刚刚开始掌握.htaccess,我已经能够美化我的网址了。

# localhost/index.php?side=kunder => localhost/kunder
RewriteRule ^([^\/\.]+)/?$ index.php?side=$1 [NC,L]

# localhost/index.php?side=kunde&id=1 => localhost/kunde/1
RewriteRule ^([^\/]*)?/([^\/]*)?$ index.php?side=$1&id=$2 [NC,L]

问题现在我似乎无法导航到位于root / favicons / favicon.ico中的我的爱好者

我猜它会如下: index.php?side = favicons& id = favicon.ico

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

您可以使用:

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/?$ index.php?side=$1 [QSA,L]

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?side=$1&id=$2 [QSA,L]