Kerry
Kerry

Reputation: 1061

htaccess retwrite subfolder to the maindomain

my domain name is www.hangings.com.au where as the project is hosted inside the folder named hangings so I need to enter something as www.hangings.com.au/hangings

Can anyone tell me how can I rewrite htaccess file so that it will show the content hosted in www.hangings.com.au/hangings when someone enters as www.hangings.com.au in their browser.

I tried something like the below

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.hangings.com.au/$1 [NC]
RewriteRule ^(.*)$ www.hangings.com.au/hangings$ [L,R=301]

but I am getting a browser error "This Website has a Redirection Loop"

Upvotes: 0

Views: 32

Answers (1)

Emii Khaos
Emii Khaos

Reputation: 10085

The redirect loop is because of www.hangings.com.au/hangings matches also the condition.

If it's enough for you, that calls to www.hangings.com.au/ are redirected to the subfolder, an nor deeper structure, the following should be enough.

    RewriteEngine on
    RewriteRule   ^/$  /hangings  [R]

Upvotes: 1

Related Questions