Redirect subdomain (HTTP & HTTPS) to another URL

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 5
Joined: 30 Jul 2012, 12:41

Redirect subdomain (HTTP & HTTPS) to another URL

30 Jul 2012, 12:47

Hi

I'm hoping someone can help me. I need to redirect a subdomain that uses both HTTP and HTTPS to a URL on another site.

So, for example :
I need http://subdomain.domain.com and https://subdomain.domain.com redirecting to http://www.anotherdomain.com/dir1/dir2/index.asp.

This would be a permanent redirect so a 301 I believe?

Any help would be much appreciated.

Thanks

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 06:42

Hello,

Try using the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP:Host} ^subdomain\.domain\.com$ [NC]
RewriuteRule ^$ http://www.anotherdomain.com/dir1/dir2/index.asp [NC,R=301,L]


Regards
Andrew

User avatar
Posts: 5
Joined: 30 Jul 2012, 12:41

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 08:05

Hi Andrew

Thanks for the reply. I've tried the code you suggested but it doesn't seem to work.

I've got the following code to force HTTPS :

Code: Select all
 RewriteCond %{HTTPS} ^(?!on).*$
 RewriteCond %{HTTP:Host} (.*)
 RewriteRule (.*) https\://%1$1 [NC,R=301]


Would this affect the code you sent me?

Thanks

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 08:49

Could be. Lets take at the rewrite.log for the testing request.
Logging issues described in FAQ

Regards
Andrew

User avatar
Posts: 5
Joined: 30 Jul 2012, 12:41

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 09:20

Hi Andrew

I was getting an error which I fixed (spelling mistake in the code) and now I'm not getting any errors in the log file but the redirect still isn't working. The log file now just says ".htaccess - Loaded successfully".

Thanks

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 09:37

That's error.log. What does rewrite.log say?

Regards
Andrew

User avatar
Posts: 5
Joined: 30 Jul 2012, 12:41

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 09:55

Ah, OK. I found rewrite.log but don't really want to post it on a public forum. Can I PM it to you?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 10:17

a) you may use helpdesk and make a refer to this ticket.

b) only registered users will see the attached log + i can delete it as soon as I see the problem.

Regards
Andrew

User avatar
Posts: 5
Joined: 30 Jul 2012, 12:41

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 10:33

Thanks Andrew, I have used the helpdesk for this.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect subdomain (HTTP & HTTPS) to another URL

31 Jul 2012, 10:52

You must have told it is uses Compatability 2. Even though there wasn't any request to the root of the sub-domain, I suggest uding:

Code: Select all
RewriteCond %{HTTP:Host} ^subdomain\.domain\.com$ [NC]
RewriuteRule ^/$ http://www.anotherdomain.com/dir1/dir2/index.asp [NC,R=301,L]


Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 10 guests