Posts

Showing posts with the label htaccess

Force your site to load securely with an .htaccess file

Image
Forcing the domain to serve securely using HTTPS (for any site) The following forces any http request to be rewritten using https. For example, the following code forces a request to http://example.com to load https://example.com. It also forces directly linked resources (images, css, etc.) to use https: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] For openlitespeed RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] If this isn't working for you, first check your line endings. Copy/paste from your web browser into a text editor may not work right, so after pasting into your text editor you should delete each line break and add it back in (line break = return key). Forcing HTTPS with WordPress If your .htaccess file already contains some  default WordPress code , enter the following above or below that code. Never enter...