WWW redirection


#1

Hello,
Like here https://support.cloudflare.com/ i have a sub-domain and it’s working but i do not want the error we can see here:
https://www.support.cloudflare.com/
So i tried to write a forwarding url rule but it’s not working.

Thank you!


#2

What’s the rule you tried? It should look something like:

www.sub.example.com/
forward to
https://sub.example.com/$2

-OR-

  1. Make sure your web server is set up to respond to www.sub.example.com as an alias for sub.example.com
  2. Add this to .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.sub.example.com$ [NC]
RewriteRule ^(.*)$ https://sub.example.com/$1 [R=301,L]
  1. Make sure your Cloudflare DNS has a :orange: A record for www.sub that points to the same IP address as sub

I think that should do it.


#3

thank you for your answer.
i tried :
www.sub.example.com/ and *.sub.example.com/

forward to

https://sub.example.com/$1
But nothing!

  1. Yes i added alias, nothing!
  2. For .htaccess i can’t use because IIS server, so i should use Web.config :
    i try from http://htaccesstowebconfig.com/

Blockquote

<system.webServer>
rule name=“rule 1h” stopProcessing=“true”
match url="^(.*)$" /
action type=“Rewrite” url="/https://sub.example.com/{R:1}" /
/rule
</system.webServer>

Blockquote

  1. I did.

Nothing!


#4

Ah ok i get it!
https://www.sub.example.com/ is not working but http://www.sub.example.com/ is working! (will redirect).
My website is all on https and i see under crypto

Blockquote
mywebsite.com, *.mywebsite.com (2 hosts)

  • shoud mean sub also?

What is the problem?


#5

Sorry, it looks like the wildcards in my page rule example didn’t show up:

> *www.sub.example.com/*
> forward to
> https://sub.example.com/$2