2013-01-22 59 views
0

那麼,我已經閱讀頁面和更多頁面的htaccess指南和問題在這裏在stackoverflow,但仍然我還沒有找到這個問題的答案。htaccess重定向GET變量沒有觸及css鏈接

我希望將網址www.domain.com/profile/1重定向到www.domain.com/profile.php?id=1,並將網址改爲www.domain.com/profile/ranisalt重定向到www.domain.com/profile.php?seo=ranisalt

我使用這個重寫規則,它已經在重定向一直不錯:

Options +FollowSymlinks 
RewriteEngine on 
RewriteRule ^profile/([0-9]+)/ profile.php?id=$1 [NC,QSA,L] 
(there is more, but not relevant) 

的問題是,在CSS如果我直接訪問profile.php?id = 1,它會正確加載(www.domain.com/css/style.css),但當我訪問該掩碼時,它會嘗試在www處查找css .domain.c om/profile/1/css/style.css,找不到。

我一直在使用這個作爲一個臨時的解決辦法

RewriteRule ^(.*)/(css|js)/(.*).(css|js)$ css/$3.$4 [L] 
RewriteRule ^(.*)/img/(.*).(jpg|png)$ img/$2.$3 [L] 

但它看起來並不整齊,美觀大方:(

我怎樣才能使加載CSS精美,正確?

回答

0

您的相對URI庫已更改,因此當瀏覽器加載類似www.domain.com/profile/ranisalt的URL時,與css之類的東西相關的鏈接將在URI的前面附加/profile/附加到URI的前端(因此可以重置爲www.domain.com/profile/css/some.css)在由生成的HTML,您需要通過添加該標籤頁面的標題添加一個URI基地:

<base href="/"> 
+0

它沒有任何改變,它仍然試圖找到/型材/ CSS /(...) – ranisalt