2016-04-12 69 views
1

當用戶訪問domain.com/test/它應該顯示domain.com/test/folder/index.php默認情況下爲.htaccess - 在子目錄中顯示文件夾的內容

index.html    <-- current homepage 
    /test/    <-- .htaccess file 
    /folder/ 
     index.php 

目前我使用:

DirectoryIndex folder/index.php

但有沒有其他辦法?我試圖重寫規則,但它不會工作:

RewriteRule ^(.*) /folder/index.php [NC,L,QSA]

+0

'重寫規則^ $文件夾/ index.php' – jeremy

+0

@Jeremy我試過這個,但是我得到了403 Forbidden錯誤。 – forloop

回答

2

您可以使用此規則/test/.htaccess:(。*)

DirectorySlash Off 
Options +FollowSymLinks 
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^[^/]*$ folder/index.php [L] 
+0

我已經試過這個,但是我得到了403禁止的錯誤 – forloop

+0

是的,它加載得很好 – forloop

+1

不知道,因爲我的答案中沒有403導致規則。在你的.htaccess的頂部嘗試'Options + FollowSymLinks + Indexes',並確保'文件夾'沒有任何.htaccess – anubhava

相關問題