Redirect all pages to non-www and HTTPS in WordPress
To redirect all URLs from www to non-www and also to redirect from http to https, this code snippet to be added to .htaccess file at the top should do the trick.
So https://example.com
# BEGIN Redirects RewriteEngine On # 301 redirect www to non-www RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] # 301 redirect to https RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # END Redirects
If you still want the www way instead https://www.example.com
# BEGIN Redirects RewriteEngine On # 301 redirect to www RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # 301 redirect to https RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # END Redirects
Hi It not working for me
I have use all methods for the redirection including adding code to the .htaccess.
None of those methods works for me.
this is not working, Am using litespeed server
Hi. Great. How do add trailing slashes to urls if some do not have it?
Thank you!