Sikander
Sikander

Reputation: 2835

.htaccess : Loads a directory by default

I have to upload a directory by default when someone comes to my static website

this is the structure

under my public_html I have domain folder 'domainname'. In domain folder I've webfolder/fr/index.html

I want to load files under webfolder/fr directly. following is my .htaccess under the domain name

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domainname$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domainname$
RewriteCond %{REQUEST_URI} !webfolder/fr/
RewriteRule (.*) /en/$1 [L]

if I remove fr/index.html it loads files under webfolder. If I set

RewriteCond %{REQUEST_URI} !webfolder/fr/

it gives 500 internal error.

Please help me how can I fix this.

To Clarify:

When I open my domain www.domain.com I want it to open www.domain.com/webfolder/fr

Upvotes: 0

Views: 47

Answers (2)

Sunny Kalariya
Sunny Kalariya

Reputation: 346

Please add following two lines to allow a specific file to load just in case there is no default index file setup already

Options -Indexes
DirectoryIndex index.html index.php

Note : if you have to load first php index file then you have set like

DirectoryIndex index.php index.html

Upvotes: 1

Parikshit Sharma
Parikshit Sharma

Reputation: 307

So you want to redirect your domain from root folder to some other subfolder

try this code

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domainname$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domainname$
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /webfolder/fr [L]

hope this code will work for you

optional:-you can also do this by changing your home directory in cpanel settings

Upvotes: 0

Related Questions