2014-10-31 114 views
0

我有一個.htaccess文件的mod_rewrite重定向根URI到index.php

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ index.php?q=$1 [QSA] 

如果我輸入網址www.domain.com/something也CSS和JS文件加載AR它工作正常。
如果我只進入www.domain.com(沒有任何參數),則問題開始 - 瀏覽器顯示空白。我需要添加什麼,以便www.domain.com打開index.php並仍然會加載所有的css文件?

我想這

RewriteRule . /index.php [QSA,L] 

,但隨後沒有的CSS文件被加載,因爲我明白,這只是重定向一切的index.php(^ $來代替。也重定向一切的index.php)

我也試過在index.php文件的開頭添加這樣www.domain.com將在PHP端

header("Location: www.domain.com/begin"); 

重定向但它仍然不能正常工作,因爲沒有已加載!

回答

0
RewriteEngine on 
RewriteCond %{REQUEST_URI} !^/index.html$ 
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$ 
RewriteRule .* /index.php [L,R=302] 

應該加載CSS,JavaScript和圖像。

+0

現在瀏覽器說這個網頁有一個重定向循環 – 2014-10-31 16:46:51

+1

我想,爲了防止循環,'!^/index.html $'應該讀取'!^/index.php $'。 – 2014-10-31 21:36:38

相關問題