I have an .htaccess
file the includes some rewrites that are doing a couple of things, which is working fine. It looks like this:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Removes .php ending from path
# ---------------
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
# Services & Knowledgebase rewrites
# ---------------
RewriteRule ^services/([a-zA-Z0-9-/]+)/([a-zA-Z0-9-/]+)$ /services.php?cat=$1&s=$2 [L]
RewriteRule ^services/([a-zA-Z0-9-/]+)$ /services.php?service=$1 [L]
RewriteRule ^knowledge-base/([a-zA-Z0-9-/]+)/([a-zA-Z0-9-/]+)$ /knowledge-base.php?cat=$1&s=$2 [L]
RewriteRule ^knowledge-base/([a-zA-Z0-9-/]+)$ /knowledge-base.php?cat=$1 [L]
</IfModule>
I have now added SSL to the site, and need to force HTTPS for the entire site. I have tried adding the following to my .htaccess
:
# Force HTTPS
# ---------------
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Just after the RewriteEngine On
statement, however when I try example.com
, the url remains as example.com
and I get the following:
Not Found
The requested URL / was not found on this server.
If I go to https://example.com
it works perfectly.
How do I force the https correctly, while retaining my other rewrite rules?
Thanks for any help
Mike