Jump to content

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/311798-resolve-website-to-one-url/
Share on other sites

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?

 

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 by kicken
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?

 

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.

  1. Someone requests the page via http://
    Whether they used www or not here isn't relevant, you just redirect them straight to https://www.
  2. 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.

 

  • Like 1

@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]
	

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.