Mobile app version of vmapp.org
Login or Join
Miguel251

: How can I force my site to serve just HTTPS and non-www? I have a WordPress install where all the links are https://example.com. So, users that try to access the site via https://www.example.com

@Miguel251

Posted in: #Apache #Https #NoWww #Redirects #Wordpress

I have a WordPress install where all the links are example.com. So, users that try to access the site via www.example.com will see the site, but none of the images and resources will load.

How do I force all users to be redirected to the same domain? I'd rather have everyone at example.com.
Is this something I can do through the domain's DNS settings, in the host/server, or in WordPress itself?

Update:
I am using Apache.

Update 2:

All the conditions I am trying to catch:

User types,

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


As I understand, conditions 5 and 6 should be the same as 1 and 2. But I put it there, just in case. Condition 3 is where I want users to go, so that should work by default.

1-6 should redirect to -> domain.com

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Miguel251

1 Comments

Sorted by latest first Latest Oldest Best

 

@Twilah146

What webserver are you running on?

Nginx

To remove www in nginx do the following.

if ($host = 'www.example.com' ) {
rewrite ^/(.*)$ example.com/ permanent;
}


That will strip the
To force https:

rewrite ^ $server_name$request_uri? permanent;


Along those lines.

Apache

Force https:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) %{SERVER_NAME}/ [R,L]


Strip www:

RewriteCond %{HTTP_HOST} ^www.(.+)$
RewriteRule ^(.*)$ %1/ [R=301,L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme