: 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
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
More posts by @Miguel251
1 Comments
Sorted by latest first Latest Oldest Best
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]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.