2014-09-21 34 views
0

我有這個網址:爲什麼我在.htaccess中使用mod_rewrite我的css文件無法使用?

http://domain.com/index.php?type=item&id=656&title=mytitle 

漢口我想在.htaccess重寫URL以便:

http://domain.com/item/656/mytitle 

我用這個ruls在.htaccess:

RewriteEngine On 
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?type=$1&id=$2&title=$3 [L] 

它的工作但我的和js檔案index.php不能正常工作

我的CSS文件鏈接

<link rel="stylesheet" type="text/css" href="file/css/style.css" /> 
+0

您是否嘗試過使用JS/CSS絕對文件路徑?編輯:糾正我,如果我錯了,但不應該有一個'/'或在該文件路徑前的'../'? – 2014-09-21 18:40:03

回答

1

閱讀有關的RewriteCond

# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
# Then... 
RewriteRule ... 

# If the uri not starts with ... 
RewriteCond %{REQUEST_URI} !^/file/css 
# Then... 
RewriteRule ... 
+0

我可以使用? – user3706610 2014-09-21 18:39:36

+0

第一個允許查看所有文件(包括.php文件)。 第二個只允許訪問以file/css開頭的url。 你也可以結合這兩個規則。 – 2014-09-21 18:46:50

相關問題