redirect http to https page

Topics: Developer Forum, User Forum
Mar 2, 2010 at 1:02 PM
Edited Mar 2, 2010 at 1:32 PM

Hi all

i have the following rewrite rule running on version 1.2.14

RewriteLog D:\modrewritelog.log
RewriteLogLevel 1
RewriteCond %HTTPS (?!on).*
RewriteRule /registerinterest.aspx [I,RP]

however, as you can gues it isnt working

can anyone tell me where im going wrong

Mar 2, 2010 at 1:28 PM

Check the documentation.  I don't believe RP is supported on IIRF v1.2

Also you may want to look into moving to v2.0 or v2.1

Mar 2, 2010 at 1:33 PM

Hi thanks for that


ive just downloaded version 2 can you tell me if my code is correct and will work in version 2?





Mar 2, 2010 at 4:15 PM

No, it sure looks like you've got some strange syntax in there.

%HTTPS is not understood by IIRF.  You need to use something like %{HTTPS} .

also your RewriteRule really needs to be RedirectRule.  If you want to rewrite, use RewriteRule.  If you want redirect, use RedirectRule.  If you don't understand the difference, check the documentation.

In place of [I,RP], I think you want [I,R=301]. 

Many good things are in the documentation.  check it out.

Mar 4, 2010 at 4:33 PM


well this is what ive managed to write so far

RewriteLog  D:\Inetpub\wwwroot\testthenations\NModRewrite\error.log
RewriteLogLevel 3

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} (?!on).*
RewriteRule ^blar\.aspx$ [NC,L]
RewriteCond %{HTTPS} on
RewriteRule ^(?!blar\.aspx)(.*)$$1 [NC,R=301,L]

is does as i want it to when going to the https section however on the blar.aspx page i have links to root pages in the format <a href="/otherpage.aspx"> but when i click on the link its leaving me in the https section

do you know what im doing wrong

Mar 4, 2010 at 5:35 PM

I'll say it again: if you want Redirect, use RedirectRule.  You are using RewriteRule, but from your description, you apparently want Redirect.

If you don't want a redirect, then you should eliminate the scheme and server (http://whatever) from the replacement string in the RewriteRule.

Here's the link for the documentation on RewriteRule, that describes its usage:

Also, it's a good practice to check the IIRF log file, or use the status inquiry page.  You will see warnings noted in both places, because of the inconsistent syntax you're using.  The log file will say: 

WARNING: Rewriting to a fully-qualified URL. Do you want RedirectRule or ProxyRule?

It will be much faster for you to diagnose your troubles yourself, than posting to the forum and asking "what am I doing wrong?" This suggestion is another of the many good things which are awaiting your discovery, in the documentation.




Mar 9, 2010 at 9:57 AM

my latest verion of the IIRF.ini file is below, all seems to be working however in ff im getting the error "warnign contains unauthenticated content" however if i disable the rewrite and just brows to the secure page i get no errors at all

can anyone help

RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_FILENAME} register.aspx
RedirectRule ^/(.*)$$1 [R=301]

RewriteCond %{HTTPS} on
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_FILENAME} !register.aspx
RedirectRule ^/(.*)$$1 [R=301]