Jump to content

htaccess: optional redirect to https


kixe
 Share

Recommended Posts

Usually I add the following lines in my htaccess files. Would be nice to have this or something similar in the core packages. Maybe somebody find this useful.
 

  # -----------------------------------------------------------------------------------------------
  # OPTIONAL: Redirect users to the non 'www.' version of the site
  # For example: http://www.processwire.com/ would be redirected to https://processwire.com/
  # -----------------------------------------------------------------------------------------------

  RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
  RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [L,R=301]

  # -----------------------------------------------------------------------------------------------
  # OPTIONAL: Force a redirect to SSL
  # For example: http://processwire.com/ would be redirected to https://processwire.com/
  # -----------------------------------------------------------------------------------------------

  # RewriteCond %{SERVER_PORT}   !^443$
  # RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...