-1

i use isapi rewirte from helicon.

i have this code for non-www to www rewrite:

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301]

works fine for the non-www to www part... than i need it the www if it is on http to be redirected to https

RewriteCond  %HTTPS (?!on).*
RewriteCond Host: (.*)
RewriteRule (.*) https\://$1$2 [I,RP, L]

what do i need to change in this so it will work?

i get https://folder/index.asp the entire domain is gone

i have tried samething else but it is not working as well, here it is:

RewriteCond %{HTTP:Host} ^(?!www\.)?(.*)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? https://(?%1www.)%2 [R=301]

if i try domain.com i got https://www. and if i tried www.domain.com i got https://www.

what it means i solved half of my problem! but why the rest of the url is not there?!

Y.G.J
  • 1,098
  • 5
  • 19
  • 44

1 Answers1

-1

My answer considers answer for ISAPI_Rewirte version 3. You get https://folder/index.asp because your host value is inside the %1, not the $1.

I'd suggest:

RewriteCond %{HTTPS} !on
RewriteCond Host: www\.(.*)
RewriteCond {REQUEST_URI} (.*)
RewriteRule .* https\://www.%1%2 [NC,R=301,L]
Andrew
  • 511
  • 3
  • 7