Created
August 24, 2019 05:33
-
-
Save Garconis/0e3d748dd248ca1e614df007ead0599c to your computer and use it in GitHub Desktop.
Cloudways | .htaccess rewrite URL to HTTPS with WWW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cloudways force HTTPS with WWW | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^example.com [NC] | |
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC] | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$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 | |
Options All -Indexes | |
# Block Attempts to Enumerate WordPress Users | |
RewriteCond %{REQUEST_URI} !^/wp-admin [NC] | |
RewriteCond %{QUERY_STRING} ^author=\d+ [NC,OR] | |
RewriteCond %{QUERY_STRING} ^author=\{num | |
RewriteRule ^ - [L,R=403] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should add both
www
andnon-www
domains in Domain Management section in your application. After that, remove the existing rules for HTTPS redirections and add the following rules in the beginning of your application's.htaccess
file:Make sure to replace
example.com
with your domain name.