2013-10-31 15 views
1

我正在我的網站上工作,並使用.htaccess文件製作了「SEO網址」。 因此,這個網站。網站/聯繫等於website.eu/index.php?file=contact。和website.eu/case/somthing equalc website.eu/index.php?file=case & ID = somthing。現在我的問題是,如果地址是website.eu/contact/這些樣式不會被加載。htaccess SEO網址包含樣式失敗..如何解決這個問題?

的htaccess:

RewriteEngine On 

RewriteOptions inherit 

Options +FollowSymlinks 
Options -Multiviews 

RewriteBase /habberdesign 

## hide .php extension 
## To externally redirect /dir/foo.php to /dir/foo 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC] 
RewriteRule^%1 [R,L,NC] 

## To internally forward /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ /index.php?file=$2.php&ID=$3 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ /index.php?file=$2.php&ID=$3 

ErrorDocument 404 /index.php?file=404.php 

RewriteRule ^countdown /countdown 

樣式:

<link href="Styles/contact.css" media="screen" rel="stylesheet" type="text/css"> 

回答

1

確保在你的CSS使用絕對路徑,JS,圖片文件,而不是相對的。這意味着您必須確保這些文件的路徑始於http://或斜槓/

可選您可以嘗試在你的頁面的頭部添加此:<base href="/" />

更新:還記得RewriteCond只適用於第二天RewriteRule。因此你的規則應該是這樣的:

Options +FollowSymlinks -Multiviews 

RewriteBase /habberdesign 

## hide .php extension 
## To externally redirect /dir/foo.php to /dir/foo 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC] 
RewriteRule^%1 [R,L,NC] 

## To internally forward /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ /index.php?file=$2.php&ID=$3 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ /index.php?file=$2.php&ID=$3 [L,QSA] 

ErrorDocument 404 /index.php?file=404.php 

RewriteRule ^countdown /countdown [L] 
相關問題