2015-06-18 50 views
0

我想提出一個尾部斜槓我的網址與.htaccess添加的.htaccess結尾斜線和CSS了可怕的

.htaccess

 RewriteEngine On 
     RewriteBase/
     RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
     RewriteRule^%1 [R=301,L] 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteCond %{REQUEST_FILENAME}.php -f 
     RewriteRule ^(.*?)/?$ $1.php [NC,L] 

當我嘗試使用www.example.com/about-us它工作正常但是當網址是www.example.com/about-us/我的css url不會加載網站會變得可怕。對不起,我的英語不好。

+0

您應該將最近的2個RewriteConditions移動到第一個RewriteCond上方 –

+0

更容易的是去除尾部的斜線。像[Laravel](https://github.com/laravel/laravel/blob/master/public/.htaccess#L9)一樣。 –

回答

0

您需要使用絕對的URL或使用基本標籤在您的網站的頭部做這些pretty URL重寫後。

使用CSS之前使用/路徑。

<link rel="stylesheet" type="text/css" href="/path/to/style.css"> 

或者你可以使用基地。

<head> 
<base href="http://www.example.com/"> 
</head> 
相關問題