Just do it in your .htaccess, it will be alot simpler. The important thing is that the rules are above WordPress’ rules. Setting L also states, that this shall be the last rule evaluated if a match was found
# Redirect to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# Redirect non-www to www
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Related Posts:
- Why is WordPress redirecting from http to https on a local environment?
- Force HTTPS using .htaccess – stuck in redirect loop
- Keeps on redirecting on my development copy
- How to redirect url requests to https? [closed]
- Redirect www to non-www htaccess
- 302 redirect instead of 301 after switch to HTTPS
- WordPress redirect loop on nginx + apache reverse proxy
- Redirect from https to http or from http to https? [closed]
- Redirect to https not working with .htaccess [closed]
- Mixed Content with SSL, wordpress behind a reverse proxy
- Menu links only using http after enabling https, unable to redirect http links
- Cant Access Website – Changed HTTP to HTTPs
- https multiple redirects
- some url does not redirect from http to https
- https redirect (with .htaccess) redirect loop
- Redirect HTTP to HTTPS
- Site redirecting from http to https [closed]
- WordPress Redirecting HTTPS Requests to HTTP
- Infinite loop behind SSL proxy on non-standard port
- What is the right way to redirect all traffic to HTTPS?
- 301 redirection editing .htaccess doesn’t work
- WordPress keeps redirecting subpages without http to https homepage after switch
- https – too many redirects
- How to use https on one page only?
- .htaccess 301 redirect conflict with plugin “WordPress Https”
- ReDirect subfolder link to another sub-folder and force SSL
- WordPress CSS/Theme gone after SSL got activated
- My site doesn’t redirect from HTTP to HTTPS
- Only execute function if SSL is set up properly
- HTTPS to HTTP rewrite rules not working as expected
- Understanding Redirects
- How to replace the links http to https
- Why https://www. SUBdomain is redirected by WP to https://MAINdomain
- WordPress site not forcing from http to https instead getting redirected too many times
- I get “too many redirects” problem when migrating localhost site
- Redirect HTTP request to HTTPS request
- Moving site from HTTP to HTTPS
- How to move a https website back to dev and access the admin?
- WordPress HTTPS – ‘… better to use HTTP for installation …’
- How to force HTTP and stop SSL completey on WordPress website
- Why Does My Website Redirect to HTTP Before HTTPS When Accessed Without a Trailing Slash?
- Does WordPress automatically redirect to the URL specified in settings?
- How to redirect all HTTP requests to HTTPS
- PHP header(Location: …): Force URL change in address bar
- What does HTTP/1.1 302 mean exactly?
- php refresh current page?
- How do you redirect HTTPS to HTTP?
- How to force a 404 on WordPress
- Disable front end to use as CMS only?
- Redirect Restricted Page to 404
- How to redirect non-logged in users to a specific page?
- How to prevent automatic redirection of 404 errors and “incorrect” URLs?
- How do I skip wordpress’s 404 handling and redirect all 404 errors for static files to 404.html?
- Disable WordPress URL auto complete
- Host the wp-admin on another domain?
- Redirect user to original url after login?
- When I change slug, will WordPress create redirect from the old URL?
- WordPress localhost site redirect to live site
- WordPress redirecting connections on port 8080 to 80
- WordPress Redirect All HTTP requests to HTTPS via .htaccess
- wp_redirect() function is not working
- Redirect entire website to a single page
- My wordpress multisite homepage redirects to signup page
- Logout redirect to home page
- Disable ONLY URL auto complete, not the whole canonical URL system
- Redirect Localhost wordpress site to dashboard
- Redirect page URL to home URL without using a plugin
- Login redirect to previous page
- How to prevent redirect to ‘About’ after core upgrade?
- 301 redirect instead of 404 when URL is a prefix of a post or page name?
- Why is wp_redirect() preferable to a standard PHP header redirect?
- How do I programmatically generate a 404?
- Redirect to referring page after logging in
- User redirect to destination URL after login
- Prevent access to single post types
- check first time login only
- How to change the default logout link on WordPress Admin
- Stop WordPress from “guessing” redirects for nonexistent URLs
- WordPress install enters an infinite loop
- How to redirect a sucessful registration to a page template?
- Stop WordPress and Plugins from Overwriting .htaccess
- How to configure nginx to redirect requests to the uploads directory to the production server?
- WordPress HTTPS redirect loop
- Why am I getting a 301 on a existing post?
- Redirect to dashboard after login
- Make a video post redirect to next post after completion
- Old blog/ and blog/feed/ URLs not working after moving blog to top-level via .htaccess
- Non-WordPress page in subdirectory under WordPress page
- How to redirect after login, the working way?
- Password change when the user login first time
- Custom login form redirect to external site
- Redirecting WordPress /.htaccess / HSTS / SSL
- 301 redirect not working through .htaccess
- handling login/logout redirects
- Clarification on auth_redirect()
- Site redirects to wrong url when saving settings
- How to redirect all requests to wp-login.php?
- Implementing global redirection (automatic redirect for all pages who had their slug changed)
- Correct way to hide pseudo pages from being shown?
- Redirect blog page to latest post?