My main public_html directory has the following .htaccess rules:
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
The problem is, I then have a subdirectory called source, and I want that directory to just list the files within it (because there is no index file). The problem is the above parent directory's htaccess rules are causing no files in source to be shown in the directory index (it just lists a blank index).
How can I solve this?
THANKS
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>
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With