• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

How to have directory indexing on subdomains [SOLUTION]

C

chillax

Guest
The problem:

Quite an annoyance that Plesk does not allow directory indexing on the root of your subdomains.
For example if you wanted to have directory indexing on sub.mydomain.com/ you cannot simply create an htaccess file with Options +Indexes and expect it to work.


The solution:

Here is what I put together, I welcome feedback from others on an easier/better way to achieve the end result.

1. Create a directory in your subdomain (ex: sub.mydomain.com/files/).

2. Move your files that you want indexed from the root directory to the one you just created.

3. Create an .htaccess inside the directory you just created and put the following text in it:
Code:
Options +Indexes
4. Create an .htacces file in your root directory and put the following text in it:
Code:
RewriteEngine On

RewriteRule ^$ /files/ [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*) /files/$1 [L]
5. Test it out by going to sub.mydomain.com and see if it shows you the directory listing of the files directory.
 
Like a charm (directory listing)

Should be an easier way but it works!.
 
Back
Top