Spob
Spob

Reputation: 259

Apache redirect question to change domain name

I am attempting to add a rewrite rule to my apache configuration file to redirect users to a new url.

The url of my site is https://openmind.scribesoftware.com. If a user enters a URL with https://openmind.scribesoft.com (note the lack of "ware") I'd like to redirect them as though they had typed the proper url.

I have tried a couple variations such as:

RewriteEngine on
RewriteCond %{HTTPS_HOST} !^openmind\.scribesoft\.com$ [NC]
RewriteRule ^(.*)$ https://openmind.scribesoftware.com/$1 [R=301,L]

However that results in the following error:

 This webpage has a redirect loop.

 The webpage at https://openmind.scribesoftware.com//enterprises/571 has resulted in too many redirects.

I already have a rewrite rule to redirect non-http requests to https requests and that is working fine.

Thanks.

Upvotes: 1

Views: 9034

Answers (1)

SimonJ
SimonJ

Reputation: 21306

HTTPS_HOST is not a real variable (see the RewriteCond docs). Use HTTP_HOST and HTTPS:

...
RewriteCond %{HTTP_HOST} !^openmind\.scribesoftware\.com$ [NC]
RewriteCond %{HTTPS} =on
...

Upvotes: 6

Related Questions