Welcome to WebmasterWorld Guest from 54.198.164.83

Forum Moderators: Ocean10000 & incrediBILL & phranque

Htaccess redirect https www

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

New User

joined:Jan 11, 2015
posts:30
votes: 0


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]

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

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14597
votes: 595


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.
7:34 pm on Apr 15, 2018 (gmt 0)

New User

joined:Jan 11, 2015
posts:30
votes: 0


how should I change this code?
1:33 pm on Apr 16, 2018 (gmt 0)

New User

joined:Jan 11, 2015
posts:30
votes: 0



I did not understand you can do an example?
2:18 pm on Apr 16, 2018 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:3675
votes: 203


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.



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

New User

joined:Jan 11, 2015
posts:30
votes: 0


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

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14597
votes: 595


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 :(
1:00 am on Apr 17, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11235
votes: 126


How do you find those?

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