bonny
bonny

Reputation: 3247

How to exclude a RewriteRule?

I have the following RewritRule in my .htaccess what causes a problem for further actions:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Now I would like to create a subdomain like folder.example.com

The problem is that when calling this domain it automatically will be added www. before folder so that it will be www.folder... because of that ReWriteRule. So my question is how can I exclude just that folder from that condition?

Thanks alot.

Upvotes: 0

Views: 46

Answers (1)

Derek
Derek

Reputation: 3435

You need to add a rewrite condition excluding the subdomain from your rewrite rule.

RewriteCond %{HTTP_HOST} !^folder\.example\.com$
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Upvotes: 1

Related Questions