2013-09-26 64 views
1

我在主文件夾(/ public_html)中有以下行中的.htaccess。這些是爲我的域上安裝的應用程序。.htaccess訪問網站根和子文件夾

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule ^$ app/webroot/ [L] 
    RewriteRule (.*) app/webroot/$1 [L] 
</IfModule> 

看起來這條規則使得每個子文件夾都不可訪問。例如,我有一個名爲/ public_htm/public的子文件夾。我希望這個子文件夾和它的所有內容都可以被公衆訪問。如果我把一個.htaccess文件放在這個子文件夾中,它需要什麼行來訪問它的內容?

回答

1

使用此代碼替換您的.htaccess:

Options +FollowSymLinks -MultiViews 

<IfModule mod_rewrite.c> 
    RewriteEngine on 

    RewriteRule ^$ app/webroot/ [L] 

    # If the request is not for a valid directory 
    RewriteCond %{REQUEST_FILENAME} !-d 
    # If the request is not for a valid file 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.+)$ app/webroot/$1 [L] 
</IfModule> 
+0

葉氏的作品。很多謝謝@anubhava的超級快速回答:) – RaduS

+1

非常歡迎。請考慮將其標記爲「已接受」,以便將來遇到類似問題的用戶將能夠輕鬆查看。 – anubhava

相關問題