SaranacLake Posted December 3, 2020 Share Posted December 3, 2020 Is it correct that Google considers these URLs as separate websites? phpfreaks.com www.phpfreaks.com http://www.phpfreaks.com https://www.phpfreaks.com I have a VPS with an SSL certificate, and I would like to know how to point everyone to this URL so I don't get dinged by Google in the search results and for SEO... https://www.MySite.com Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/ Share on other sites More sharing options...
requinix Posted December 3, 2020 Share Posted December 3, 2020 www versus no-www matters. http vs https should not. Canonicalize everything and redirect appropriately. Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/#findComment-1582795 Share on other sites More sharing options...
SaranacLake Posted December 3, 2020 Author Share Posted December 3, 2020 2 minutes ago, requinix said: www versus no-www matters. http vs https should not. Canonicalize everything and redirect appropriately. So how do I redirect someone from "mysite.com" to "www.mysite.com"? And how do I force an HTTP url to HTTPS for security? Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/#findComment-1582796 Share on other sites More sharing options...
kicken Posted December 3, 2020 Share Posted December 3, 2020 (edited) This concept has to do with Canonical URLs, you should choose which URL format you want and the redirect everything else to that one format through either your code or server configuration. In simple cases the search engines may figure it out, but it's best if you control the process yourself. There are a number of resources out on the web that can show you how to redirect your requests appropriately for whatever software you're using. For example: Apache force www. Edited December 3, 2020 by kicken Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/#findComment-1582798 Share on other sites More sharing options...
SaranacLake Posted December 3, 2020 Author Share Posted December 3, 2020 5 minutes ago, kicken said: This concept has to do with Canoical URLs, you should choose which URL format you want and the redirect everything else to that one format through either your code or server configuration. In simple cases the search engines may figure it out, but it's best if you control the process yourself. There are a number of resources out on the web that can show you how to redirect your requests appropriately for whatever software you're using. So do I need two rewrites? The first rewrite to make any non-www URLs to www ? And then a second rewrite to make all www URLs https://www ? Or do I approach things from converting all non-www to https://www ? And then convert any www or http://www to https://www ? The point being that there are lots of combinations here, and I'm not sure what is the best way to do rewrite and redirects using my .htaccess file on my VPS? Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/#findComment-1582799 Share on other sites More sharing options...
kicken Posted December 3, 2020 Share Posted December 3, 2020 There's really only two conditions you need to be concerned with, thus you only need two rewrites. Both of these rewrites should send the user directly to the preferred URL so there's only one redirect. Someone requests the page via http:// Whether they used www or not here isn't relevant, you just redirect them straight to https://www. Someone requests the page via https:// (no-www) Redirect them to https://www. If you're just googling for code to drop in, you might find implementations that chain instead, ie: http://$domain -> https://$domain -> https://www.$domain. While that works, it's inefficient and unnecessary. 1 Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/#findComment-1582803 Share on other sites More sharing options...
requinix Posted December 4, 2020 Share Posted December 4, 2020 Often those two conditions can be combined into one actual rewrite: move to https://www if the request is http or it's not www. Like for Apache, a RewriteCond with [OR] plus another RewriteCond. Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/#findComment-1582811 Share on other sites More sharing options...
SaranacLake Posted December 4, 2020 Author Share Posted December 4, 2020 @kicken How does this look... # REWRITE TO WWW #------------------------------------------------------------------------------- # RewriteCond %{HTTP_HOST} !^www\. [NC] # RewriteRule ^(.*)$ https://www.%{HTTP_HOST}$1 [L,R=301] # REWRITE TO HTTPS #------------------------------------------------------------------------------- #RewriteCond %{HTTPS} !=on #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/#findComment-1582813 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.