John Anderson
John Anderson

Reputation: 551

multiple conditions in .htaccess redirect with both if and or

Im trying to setup htaccess to redirect from "domain.com" to "www.domain.com" if request is not "t.domain.com"

Below takes care of the first part:

    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

But how do I extend this to not do a redirect if the request is "t.domain.com"?

Thanks!

Upvotes: 1

Views: 1291

Answers (1)

anubhava
anubhava

Reputation: 784898

You can use:

RewriteCond %{HTTP_HOST} !^(www|t)\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Upvotes: 1

Related Questions