Darren Parker
Darren Parker

Reputation: 79

.htaccess redirect effecting sub-domains

I'm unfamiliar with .htaccess files so please give me the benefit of the doubt if what I have so far is completely incorrect.

I cannot point my domain to a sub-folder with my current hosting company and have had to use an .htaccess file to do this. Below is what I have so far to point my domain to a "website" folder.

The issue I have is that there are also other sub-folders in the root that contain my CMS etc and are accessed via an sub domain, however... now that I'm using this .htaccess file all sub domains no longer work (500 error).

Is there a way that I can allow sub-domains to not be effected by this redirect?

Options +FollowSymlinks -MultiViews
RewriteEngine On

RewriteCond %{REQUEST_URI} !^website
RewriteRule ^(.*)$ website/$1 [L]

Kind regards.

Upvotes: 2

Views: 160

Answers (1)

anubhava
anubhava

Reputation: 785128

Add a RewriteCond %{HTTP_HOST} to restrict your rule to main domain:

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/website(/.*|)$ [NC]
RewriteRule ^(.*)$ website/$1 [L]

Upvotes: 3

Related Questions