Like the title says, I am trying to figure out the best way to configure my htaccess file to redirect www URLs to non-www (I’ve noticed Google search chose to index some www page as canonical and some none, so thought this could help…?)
I’ve found this here, but it also redirects http to https, which my hosting provider already does, and thought too many redirect requests may cause issues…
depending on your hosting provider (especially if they’re already doing automatic https redirect) you might be able to configure the www subdomain to redirect to non-www without needing to use htaccess at all.
also, did you replace the .htaccess file that’s included with kirby with the snippet posted above? that might be the explanation if something doesn’t work
Hi @bruno, thanks for the reply! I didnt apply this yet in my htaccess since I saw its also redirecting https—>https, so thought I’d modify it first. Thought it shouldn’t be complicated.
The hosting support said I should check the Kirby documentation, but maybe they were being lazy anyways, if there’s a correct way to modify it and remove the https redirect I would prefer it.
ok, i don’t have much to say then – i also don’t know much about htaccess. the snippet looks fine to me. if i understand it correctly, it only redirects if the page is accessed without https. Maybe somebody else has anything to say about it, otherwise I’d just apply it, see what happens, and if something breaks, revert your changes
I haven’t yet @texnixe. The hosting support suggested this may cause “too many redirects error”, so thought I’d ask here before…
So just to make sure I understand, this code above is conditional meaning if https is already pushed, it won’t apply?
Just for my own knowledge, would something simpler and clean like this work (found it also on one of your replies on another thread ) :