2012-01-20 74 views
0

我有類似的東西:ModRewrite和URL

的.htaccess:

RewriteRule ^news/?(\d+)/?$ /?pg=news&id=$1 [NC] 

的header.php:

<link rel="stylesheet" href="../theme/style.css" media="all" > 

的問題是:當我去WWW .domain.com/news/241我收到style.css文件的錯誤「404 Not Found」。

我用<?=HOST;?>/theme/style.css替換了../theme/style.css,其中HOST是域名。如何做得更好?

回答

2

只需使用您的所有鏈接/資產(JS,CSS,圖像等)的絕對路徑:

/theme/style.css 
1

你需要在你面前重寫規則,排除您的內容目錄重寫規則:

RewriteRule ^(images¦javascript¦theme) - [L] 

上述規則告訴mod_rewrite以排除匹配的目錄