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
- php refresh current page?
- Host the wp-admin on another domain?
- WordPress localhost site redirect to live site
- WordPress Redirect All HTTP requests to HTTPS via .htaccess
- wp_redirect() function is not working
- Prevent access to single post types
- WordPress HTTPS redirect loop
- 301 redirect not working through .htaccess
- handling login/logout redirects
- Temporary redirect prevents getting $_POST array
- Moving variables from one page to another
- How to create a 301 redirect that doesn’t apply to subsites
- How to target specific user role?
- How to redirect user to a specific page based on username?
- forward domain name to particular page?
- htaccess 301 Redirect not working for WordPress site
- Auto-detect the redirect url from the original url
- WordPress Auto-Redirecting on 404
- Redirecting Pages That No Longer Exist — But Could in the Future
- About to migrate site to new domain
- Redirect all users to dashboard unless custom post type
- Redirecting connection from IP to localhost
- WordPress index.php seems to perform unwanted redirect 301
- Issue redirecting ‘blog’ to ‘news’ in WordPress using .htaccess
- Use two different index pages
- Redirect /home to home.php
- WordPress localhost site always redirect to live site [closed]
- Redirect wordpress website’s subpage to root [closed]
- Redirect old query string URLs to new add_rewrite_rule URL
- Temporary Infinite Redirect Loop
- Interested in redirection techniques for one-page themes
- Select post from dropdown and add query args not working
- Add new post redirection [closed]
- Blog keeps redirecting to the contact page
- WordPress Pagination – 301 Redirect Issue
- Why do my new WordPress pages redirect to home / staging site?
- WordPress multi domain: page redirect to main domain whenever WordPress do the URL guessing issue
- Puzzled at HTTP/2 301 response header
- date based redirect in wordpress
- How to avoid redirect 302 in wordpress to the author pages?
- ErrorDocument 410 gives me back a 302 header
- Mailjet Email Subscription + Redirect w/ Custom Template Fails
- Can’t access WP-Admin via HTTPS
- htaccess Redirect 301 doesn’t work. How to debug?
- Having a different landing page for returning users
- How to create multiple Rewrite-Rule for various site in single htaccess?
- Redirect affecting development folder
- How do I skip wordpress’s 404 handling?
- All devices on my network redirect me to an old domain
- how to write 301 redirect code for woocommerce product
- My WordPress site redirects to port 8082
- wp-login.php redirect problem
- How to redirect 404s that generated for css&JS files?
- How to Block WordPress from subdomain?
- WordPress redirect to splash page once a day for the first week
- after logout, get_current_user_id still holds value
- How can I redirect foreigners by IP to other URL in WordPress?
- How to change Ugly link?
- WordPress site redirecting to developers URL
- Best way to redirect all HTTP to HTTPS in IIS