Wednesday 15 January 2014

.htaccess - How do I set canonical URLs and redirect to https? -



.htaccess - How do I set canonical URLs and redirect to https? -

i have redirects working http https, canonicalization non www urls redirect www version…well, sort of.

http://www.domain.com redirects https://www.domain.com

http://domain.com redirects https://www.domain.com

https://www.domain.com loads fine

however, https://domain.com won't connect (different browsers give different messages).

i verified mod_rewrite enabled. here's code below:

#redirect ssl rewritecond %{http:x-forwarded-proto} !https rewriterule ^.*$ https://%{server_name}%{request_uri}[r01,l] #canonicalization rewritecond %{http_host} !^www.domain.com$ [nc] rewriterule ^(.*)$ https://www.domain.com/$1[l,r01]

two questions:

1.) why doesn't https://domain.com route https://www.domain.com?

2.) i've seen flag r=301 redirects, r01 mean?

thanks!

you can combine 2 this:

rewritecond %{http:x-forwarded-proto} !https [or] rewritecond %{http_host} !^www.domain.com$ [nc] rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301]

a few things:

r01 incorrect, it's not flag, , have caused 500 error if wasn't missing space before flags you're missing space separates target url , flags: $1[l,r01] ends beingness interpreted part of target url.

.htaccess mod-rewrite

No comments:

Post a Comment