markphd
markphd

Reputation: 1454

.htaccess - Display content of folder in a subdirectory

When user visits domain.com/test/ it should display domain.com/test/folder/index.php by default.

index.html             <-- current homepage
   /test/              <-- .htaccess file
     /folder/
       index.php

Currently I use:

DirectoryIndex folder/index.php

But is there any other way? I tried RewriteRule but it won't work:

RewriteRule ^(.*) /folder/index.php [NC,L,QSA]

Upvotes: 1

Views: 1346

Answers (1)

anubhava
anubhava

Reputation: 785196

You can use this rule in /test/.htaccess:

DirectorySlash Off
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^/]*$ folder/index.php [L]

Upvotes: 2

Related Questions