Forum Moderators: Robert Charlton & goodroi
[edited by: phranque at 8:55 am (utc) on Mar 6, 2017]
[edit reason] exemplified "mydomain" [/edit]
Does this mean that we would need to create over 500 entries of 301 redirect in .htaccess to retain search engine ranking? Or is there a simple bulk method?
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTP_HOST} !^www\.example\.com$ [OR]
RewriteCond %{SERVER_PORT} ^80$
And then the rest of your existing first rule. The [OR] connector only applies to these two lines; nothing else will change. RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [OR]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] https://%{SERVER_NAME}%{REQUEST_URI} does not explicitly indicate that it should go to www version . So search engines will see both www and non-www version within https:// ? Or maybe I am reading it wrong?
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]needs to be complete Also, I'm wondering the rewrite rule that showshttps://%{SERVER_NAME}%{REQUEST_URI}
does not explicitly indicate that it should go to www version
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [OR]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Then your other stuff [edited by: keyplyr at 2:39 am (utc) on Mar 6, 2017]
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [OR]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [OR]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
Given my conditions above, if I just leave AutoSSL enabled by default and the free Cpanel certificate installed in my domain name, will this cause duplicate content issues for many search engines especially Google?
Does this mean that we would need to create over 500 entries of 301 redirect in .htaccess to retain search engine ranking? Or is there a simple bulk method?
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteEngine On RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [OR]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [OR]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] [edited by: phranque at 9:51 am (utc) on Mar 6, 2017]
these two rulesets are redundant:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
[edited by: phranque at 1:00 pm (utc) on Mar 6, 2017]
[edit reason] unlinked patterns for clarity [/edit]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [OR]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] the second gets rid of the non-secure error if using 3rd party remote apps or content that isn't HTTPS
The Host request-header field specifies the Internet host and port number of the resource being requested, as obtained from the original URI given by the user or referring resource
With regards to your question about the REQUEST_URI exclusions, those are actually being added automatically by Comodo/cPanel before every RewriteRule so I unfortunately won't be able to control that.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [OR]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
my internal linking structure can be https://
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [OR]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [OR]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] Will the above simple code also at the same time help me pass Google pagerank from external links, meaning other sites that links to mine using a non-https and both www and non-www url?
HTTP/1.0 requests will not include a Host header, so the value will be blank.
I was taught this too, and still have the (blahblah)? business in htaccess. But is it really true? Pulling up the most recent day's logs, looking for HTTP/1.0 and then cross-checking against header logs, everything does have a "Host:" header. (And it isn't added by my host*. I asked about it once.)
HTTP/1.0 requests include a Host header at my server.
In fact, any time you have more than one hostname on the same server, wouldn't you pretty well have to include a Host: header?
check out the protocol definition - Hypertext Transfer Protocol -- HTTP/1.0:Dated May 1996. Again, HTTP/1.0 requests include a Host header at my server. Guess things have changed since that document was written
[ietf.org...] [ietf.org]
no Host header definition for HTTP/1.0...
remember that HTTP_HOST is a "HTTP headers" variable and SERVER_NAME is a "server internals" variable.
HTTP/1.0 requests include a Host header at my server.Which, by amazing coincidence, happens to be the same as ... ;)