2013-09-26 63 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

相关问题