Skip to content

Instantly share code, notes, and snippets.

@joshhartman
Forked from anonymous/.htaccess
Created October 24, 2015 15:44
Show Gist options
  • Save joshhartman/2c5ce661ff38b32070e5 to your computer and use it in GitHub Desktop.
Save joshhartman/2c5ce661ff38b32070e5 to your computer and use it in GitHub Desktop.
SSL Proxy Redirect to HTTPS (compatible with Network Solutions web hosting)
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@coloradocory
Copy link

Thank you! NS didn't make it easy for a simple htaccess https redirect.

@fastasleep
Copy link

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.

@ERIK4455
Copy link

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

@cliff-e11group
Copy link

I tried the .htaccess route and was unsuccessful. I was able to get it working with a plugin though:

  1. Upload your site, but don’t install your certificate immediately.
  2. Do not force SSL via wp-config.php
  3. Make sure the siteurl and home variables in your wp_options table are both using http:// not https://
  4. Install the free version of the Really Simple SSL plugin https://wordpress.org/plugins/really-simple-ssl/
  5. Activate the plugin
  6. 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

  1. Enable your SSL certificate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment