Rewriting subdomains

Topics: Developer Forum, User Forum
Oct 1, 2011 at 6:19 PM
Edited Oct 2, 2011 at 6:31 PM

Hello -

 

Apologies if this has been asked before, but I'm having trouble writing a redirect rule and was hoping you could shed some light on how it worked. I've read the manual and seen a similar issue that you've responded to that seems related, but I am still not able to match and redirect as expected. This is clearly not a shortcoming of your great software, but definitely a shortcoming in my ability to understand how it works. :)

Here's the first rule:

 

For ANY request that is NOT on port 81, take the subdomain portion of the request and redirect to the https version of the same request (in our servers, port 81 means that it came in on https)


RewriteCond %{SERVER_PORT} !^81$

RewriteCond %{HTTP_HOST} ^(.*)\.MYDOMAIN\.com$       

RedirectRule ^/(.*)$ https://*1.MYDOMAIN.com/$1 [R=301]

 

The second rule is:

 

For ny request that didn't match the first rule (since it would have redirected), which means it IS coming in on a secure request, see if the request is coming in for a page like this;
https://subdomain.mydomain.com/issues/detail.aspx?IssueID=XXXX (where XXXX is a number)

redirect it to

https://subdomain.mydomain.com/issues/order/XXXX


# /issues/detail.aspx?IssueID=XXXX -> /issuetracker/issues/order/XXXX

RewriteCond %{HTTP_HOST} ^(.*)\.MYDOMAIN\.com$   

RewriteCond ^/(.*)$ ^/issues/detail\.aspx\?IssueID\=([0-9]+)$ [I]

RedirectRule ^/(.*)$ https://*1.MYDOMAIN.com/issues/order/*2

 

Thank you so much for any help.

-m

Coordinator
Oct 2, 2011 at 7:26 PM

turn on IIRF logging, view the log, see what it's doing, compare to what you think it should be doing. For this basic stuff, you can use logging at level 2.

Oct 3, 2011 at 5:00 AM

I got it - for those wondering, my rule looks like this:

 

 

RewriteCond %{SERVER_PORT} !^81$

RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com$   [I]   

RedirectRule ^/(.*)$ https://*1.mydomain.com/$1 [R=301]