.htaccess 参数 - 禁止管理系统上的规则



我正在尝试使用.htaccess的新东西,但遇到了一些困难。

www.domain.com/page
www.domain.com/category/page
www.domain.com/category/section/page

我想使用 htaccess 来使用:函数.php并抓住"页面"来编写代码。

RewriteEngine on
RewriteCond %{HTTP_HOST} . 
RewriteCond %{HTTP_HOST} !^www.domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^([a-z0-9-_]+)/?$ function.php?id=$1 [L,QSA]

我面临的问题是。我不希望此规则适用于我的管理系统。www.domain.com/adminsystem

第二个是,由于某种原因,当我使用上述.htaccess代码时,我的网络字体无法识别:

@font-face {
font-family: 'gibsonregular';
src: url('/css/webfonts/gibson_regular/Gibson-Regular-webfont.eot');
src: url('/css/webfonts/gibson_regular/Gibson-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('/css/webfonts/gibson_regular/Gibson-Regular-webfont.woff2') format('woff2'),
url('/css/webfonts/gibson_regular/Gibson-Regular-webfont.woff') format('woff'),
url('/css/webfonts/gibson_regular/Gibson-Regular-webfont.ttf') format('truetype'),
url('/css/webfonts/gibson_regular/Gibson-Regular-webfont.svg#gibsonregular') format('svg');
font-weight: normal;
font-style: normal;
}

网上有很多 tutes:htaccess,但我似乎找不到一个可以解决我困境的人。

下面的代码解决了我的困境。基本上,它查看是否存在实际的文件/文件夹。如果是这样,则不要执行任何操作。如果没有,那就做它的工作。

RewriteBase /
RewriteRule ^function.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ function.php?id=$1 [L,QSA]

最新更新