Forum Moderators: phranque

Message Too Old, No Replies

Htaccess redirect https www

         

analis

5:34 pm on Apr 15, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi I have a doubt I used this code in the .htaccess file to go to https, the migration has already happened.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %]{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


The URL of my site is:

https://www.example.com

this redirect is wrong goes to https://example.com without www?

How can I fix if it's wrong?


thank you



[edited by: not2easy at 7:15 pm (utc) on Apr 15, 2018]
[edit reason] unlinked with 'example.com' for readability [/edit]

lucy24

7:29 pm on Apr 15, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do not use HTTP_HOST in a canonicalization redirect. Instead, have two RewriteCond, separated by [OR]: one to check for HTTPS, and the other to check for the exact preferred form of the hostname. (We can hash out the Proxy part later.)

Use “example.com” (or example.org, example.net, example.in et cetera) to keep from auto-linking in posts. When this isn't possible, as with HTTP_HOST, put your text inside [ code ] markup.

HTTPS redirects are currently the single most common question getting asked in this subforum, so a quick forums search should turn up many, many examples.

analis

7:34 pm on Apr 15, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month



how should I change this code?

analis

1:33 pm on Apr 16, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month




I did not understand you can do an example?

not2easy

2:18 pm on Apr 16, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It's nothing personal, but I think that the message was to try a search since there are thousands of similar questions in this forum. The Search feature is in the upper right corner of every page and can save you (an others) time when you need an answer. As mentioned in the Charter [webmasterworld.com] under Forum Etiquette:

It is not appropriate to expect other members to write your code for you or to debug your entire project; Please don't expect other members to solve a problem you don't want to begin solving yourself.

Don't get upset if someone has the answer but wants to provide you with resources and material to help you solve it on your own. After all, the most educational threads are those where members learn how to help themselves. Such threads also prove to be of most value the next time someone has a similar question.



analis

4:00 pm on Apr 16, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month



thanks anyway

lucy24

10:16 pm on Apr 16, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As mentioned in the Charter
How do you find those? I know that every subforum has a charter, but when I look for one I can never find it :(

phranque

1:00 am on Apr 17, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



How do you find those?

it is hidden in the "Forum Options" dropdown menu.