-
-
Save joshhartman/2c5ce661ff38b32070e5 to your computer and use it in GitHub Desktop.
RewriteEngine on | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] |
0
This is the ONLY Clean way to Redirect with Networksolutions. Took me hours of testing. Works best for SEO. Network Solutions is a challenging Hosting platform.
This will work .htaccess all you replace is changeexample.com with your domain. Easy.
Base Redirects
Turn on Rewrite Engine
RewriteEngine On
Remove trailing slash from non-filepath urls
RewriteCond %{REQUEST_URI} /(.+)/$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ https://changeexample.com/%1 [R=301,L]
Include trailing slash on directory
RewriteCond %{REQUEST_URI} !(.+)/$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ https://changeexample.com/$1/ [R=301,L]
Force HTTPS and remove WWW
RewriteCond %{HTTP_HOST} ^www.(.)$ [OR,NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.)$ https://changeexample.com/$1 [R=301,L]
Best of Luck! This is current as of 05/14/2021
I tried the .htaccess route and was unsuccessful. I was able to get it working with a plugin though:
- Upload your site, but don’t install your certificate immediately.
- Do not force SSL via wp-config.php
- Make sure the siteurl and home variables in your wp_options table are both using http:// not https://
- Install the free version of the Really Simple SSL plugin https://wordpress.org/plugins/really-simple-ssl/
- Activate the plugin
- It should prompt you to update your wp-config with the following, but do it either way:
//Begin Really Simple SSL Server variable fix
$_SERVER["HTTPS"] = "on";
//END Really Simple SSL
- Enable your SSL certificate
THANK YOU. What a pain in the ass. Now trying to figure out the syntax to also add 'www' to the URL in the same rewrite.