.htaccess访问Web根目录和子文件夹

时间:2013-09-26 08:59:43

标签: regex .htaccess mod-rewrite

我在主文件夹(/ public_html)中有.htaccess,其中包含以下行。这些是我在我的域上安装的应用程序。

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

似乎此规则使每个子文件夹都无法访问。例如,我有一个名为/ public_htm / public的子文件夹。我希望这个子文件夹及其所有内容都可供公众访问。如果我在这个子文件夹中放入一个.htaccess文件,它需要哪些行才能访问它的内容?

1 个答案:

答案 0 :(得分: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>
相关问题