Rewrite Not Working

Topics: Developer Forum, Project Management Forum, User Forum
May 18, 2010 at 1:36 PM
Edited May 18, 2010 at 1:51 PM

Let me preface this, by stating upfront that I am not a developer by trade. :o)

I've got a SSL for mydomain.com, not www.mydomain.com. Right now, I'm forwarding all requests for mydomain.com to https://mydomain.com with an IIS redirect and that is working fine.

When I attempt to go to www.mydomain.com, I get "This page must be viewed over a secure channel". If I use https://www.mydomain.com, I get "The security certificate presented by this website was issued for a different website's address."

So I loaded the IIRF Rewrite, but it's not working right. Here's the script:

RewriteCond %{HTTP_HOST} ^secure\.mydomain\.com$
RewwriteCond %{HTTPS} ^off$
RedirectRule ^/(.*)$ https://mydomain.com/$1

This is what I get in the logfile:

Tue May 18 08:27:52 -  5372 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue May 18 08:27:52 -  5372 - HttpFilterProc: cfg= 0x01D44400
Tue May 18 08:27:52 -  5372 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Tue May 18 08:27:52 -  5372 - DoRewrites
Tue May 18 08:27:52 -  5372 - DoRewrites: Url (no decoding): '/html/index.asp'
Tue May 18 08:27:52 -  5372 - EvaluateRules: depth=0
Tue May 18 08:27:52 -  5372 - EvaluateRules: no RewriteBase
Tue May 18 08:27:52 -  5372 - EvaluateRules: Rule 1: 2 match
Tue May 18 08:27:52 -  5372 - EvaluateRules: Rule 1: evaluating condition
Tue May 18 08:27:52 -  5372 - EvalCondition: Cond t(%{HTTP_HOST}) op(|) p(^www\.mydomain\.com$) => FALSE
Tue May 18 08:27:52 -  5372 - EvalConditionList: rule 1, FALSE, Rule does not apply
Tue May 18 08:27:52 -  5372 - EvaluateRules: returning 0
Tue May 18 08:27:52 -  5372 - DoRewrites: No Rewrite
Tue May 18 08:27:52 -  5372 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue May 18 08:27:52 -  5372 - HttpFilterProc: cfg= 0x01D44400
Tue May 18 08:27:52 -  5372 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue May 18 08:27:52 -  5372 - HttpFilterProc: cfg= 0x01D44400
Tue May 18 08:27:52 -  5372 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue May 18 08:27:52 -  5372 - HttpFilterProc: cfg= 0x01D44400

 

Any ideas??

Thanks!!!!<!----><!---->

Coordinator
May 18, 2010 at 10:18 PM

The log fragment you posted doesn't correspond to your ini file.
Something is different, I suspect as a result of the find/replace you did, to obscure the hostnames.

in any case from the log it appears that the RewriteCond that references HTTP_HOST, is returning FALSE.

That means the rewrite won't happen.  

So, check your hostname on the request, and in the rule.

 

May 19, 2010 at 1:12 PM
Edited May 19, 2010 at 1:17 PM

Thanks for the reply. You're right, the secure in the script is actually replaced by 'www', but let me check the script again and verify.

This is what the correct script looks like:

RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RedirectRule ^/(.*)$ http://mydomain/$1

 

 

Thanks again!!!

May 19, 2010 at 2:04 PM

 

RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RedirectRule ^/(.*)$ http://mydomain.com/$1

Here's my new logfile entry:

Wed May 19 09:01:14 -  8232 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed May 19 09:01:14 -  8232 - HttpFilterProc: cfg= 0x01D04400

Also, as I stated before, I have IIS redirecting all requests for mydomain.com going to https://mydomain.com successfully, but can I alter the script to go straight to https instead of http?

Thanks again!!!

Coordinator
May 19, 2010 at 2:40 PM
Edited May 19, 2010 at 2:41 PM

yes, you can alter the IIRF ini file to redirect to an https: url.

The problem I saw in your original log snip was that the hostname on the request did not match the hostname in the rule.
This was separate from the cut-n-paste error I pointed out.

I suspect that problem might be continuing.
I can't tell from the two additional lines of logfile that you posted.

 

May 19, 2010 at 7:04 PM

Thanks again for the reply. I think it's working somewhat. If I go to http://www.mydomain.com, it says "This page must be viewed over a secure channel". If I make it https://www.mydomain.com, it successfully redirects me to https://mydomain.com.  

Here's my script:

RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RedirectRule ^/(.*)$ https://mydomain.com/$1

So I guess my next question is what can I add to this to automatically redirect to the https site?

Coordinator
May 19, 2010 at 7:17 PM

I don't know - the rule you just showed should work for http or https.

Your IIRF log file will tell you what is really happening.

Also a http trace using Fiddler can be helpful in figuring out what requests and responses are passing back and forth.

May 20, 2010 at 1:41 PM

The tweaking of the code worked. Thanks again!!!!!!