2013-01-11 38 views
1

我需要一些簡單的幫助,我的htaccess文件,提前謝謝你。.htaccess重寫不影響相對圖像/ CSS/JS URL?

我有一些網站網址,如:

  • www.site.com/index.php?page_path=solutions-overview.html
  • www.site.com/index.php? page_path =解決方案,a.html

我想用RewriteEngine敘述來改變上述鏈接到分別如下:

  • www.site.co M /解決方案/概述
  • www.site.com/solutions/a

下面是我使用的.htaccess代碼:

RewriteEngine On 
RewriteRule ^solutions/overview index.php?page_path=solutions-overview.html 
RewriteRule ^solutions/a index.php?page_path=solutions-a.html 

這個工作,但是我所有的圖像,CSS文件和JS文件不再加載,因爲該頁面正試圖獲取錯誤的URL。例如,「/images/blah.jpg」改爲加載爲「/solutions/images/blah.jpg」。

如何修改htaccess代碼以防止相對URL更改?

謝謝!

+0

可能重複http://stackoverflow.com/questions/3250769/mod-rewrite - 和 - 靜態頁) –

+0

[Ignacio的答案](http://stackoverflow.com/questions/3250769/mod-rewrite-and-static-pages/3250856#3250856)在這是一般模式... –

+0

謝謝,但這沒有幫助。我找不到使用htaccess的解決方案。對於任何感興趣的人 - 我通過將以下內容添加到HTML的「的頭部來解決此問題,以便始終解析相對URL – ghilton

回答

2

此行<BASE href="http://www.yoursitename.com/">添加到您的網頁<head>標籤內,如下所示:

<head> 
    <title>Your site title</title> 
    <BASE href="http://www.yoursitename.com/"> 
    .... 
</head> 
[國防部重寫和靜態頁面(的