How to stop sub directory inheriting parent's htaccess rules

后端 未结 2 1807
我在风中等你
我在风中等你 2020-12-15 04:22

My main public_html directory has the following .htaccess rules:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

# i         


        
相关标签:
2条回答
  • 2020-12-15 04:49

    This may be obvious and you've already tried it - but have you created an .htaccess file in the subfolder of interest? Any settings in this file will override equivalent settings in the root folder.

    UPDATE:

    For the root .htaccess file, instead of IndexIgnore */* ... try Options -Indexes

    Then, in the subfolder's .htaccess file, place this single line: Options +Indexes

    Does that achieve the desired effect?

    0 讨论(0)
  • 2020-12-15 04:51

    Change your .htaccess with this:

    Options +FollowSymLinks
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # if request is not for the /sub-dir/
    RewriteCond %{REQUEST_URI} !^/sub-dir/ [NC]
    # otherwise forward it to index.php
    RewriteRule . index.php
    </IfModule>
    
    0 讨论(0)
提交回复
热议问题