I have a site which I am trying to completely redirect from http
to https
.
I need to redirect any user that arrives at the site via http
to the same page on https
.
The site is hosted on a provider's shared hosting. Since the domain's SSL certificate was installed, a new IP address has been assigned to the domain.
I have been advised that the following code should be added to my .htaccess
file. There are also some rules which handle SEO friendly URLS.
RewriteEngine On
RewriteBase /
# enforce https and www
RewriteCond %{SERVER_PORT} !=443 [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,NE,R=302]
# skip further rules for files and directories
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# internal rewrite rules
RewriteRule ^([\w-]+)/([\w-]+)/?$ page.php?venue=$1&artist=$2 [L,QSA]
RewriteRule ^([\w-]+)/?$ page.php?venue=$1 [L,QSA]
For some reason, the addition of this code to the .htaccess
file, results in a redirection loop error. I have tried variants of the RewriteCond %{SERVER_PORT} !=443
line as advised on other Stack Overflow posts, but nothing seems to work.
Does anyone have a solution?