2013-04-22 24 views
2

我想的webapp /每​​當請求任何路徑/頁的index.php加載。因此,我把我的htaccess的.htaccess重寫,如果沒有路徑進入

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ /webapp/index.php?_path=$1 [L,QSA] 

這適用於任何路徑下,雖然沒有頁面給出,它似乎並沒有工作。如何在申請「/」時應用相同的規則?

+0

我們能談談*(如果您的問題仍然沒有解決)*:http://chat.stackoverflow.com/rooms/28210/servant – 5ervant 2013-04-22 12:07:31

回答

1

也許這個作品:

RewriteRule ^($|.*) /webapp/index.php?_path=$1 [L,QSA] 

或者你可以嘗試在此情況下,.htaccess文件是沒有根或DirectoryIndex的未設置:

DirectoryIndex index.php 

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} ^($|.*)   [NC] 
RewriteRule .* /webapp/index.php?_path=%1 [L,QSA] 
+0

都能跟得上:(仍然沒有。 – 2013-04-22 11:35:53

+0

有什麼測試URL? – 2013-04-22 11:37:46

+0

url1:domain.com(不工作); url2:domain.com/randomword(works) – 2013-04-22 11:39:22

0

替換.+.*(0或更多個字符)(一個或多個字符)。即:

RewriteRule ^(.*)$ /webapp/index.php?_path=$1 [L,QSA] 
+0

嗯。不要認爲它的工作。我改成了「重寫規則^(。*)$ /webapp/index.php?_path=$1 [L,QSA]」 還不行,只是顯示目錄結構 – 2013-04-22 11:03:29

相關問題