0

It's the first time I've used 123-reg for website hosting (I usually use another host). The site has an SSL certificate and the htaccess file redirects to https:// HOWEVER... it's not removing the html extensions from the pages (it DID remove them when it was http:// )

123-reg say it's something I'm doing or not doing at my end, but the following htaccess code works just fine with my other host, just not 123-reg.

htaccess code I'm using (which also directs to https:// )

RewriteEngine On
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

Here's the website url: https://buyrich.co.uk/

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Batty
  • 1
  • What error do you get when you go to an html file without. html extension at the end? – Amit Verma Feb 02 '18 at 16:13
  • I don't get an error code if I remove the html extension manually but as soon as I click onto another page, the html extension re-appears – Batty Feb 02 '18 at 17:03
  • The rule you are using doesn't remove `.html` extension. It just makes it so that you can access your html files even without `.html` . If you want to remove .html extension completely from your urls ,see the following post https://stackoverflow.com/questions/5730092/how-to-remove-html-from-url – Amit Verma Feb 02 '18 at 17:21
  • I checked out that post and added the following code to the htaccess file but that isn't working either? Do I need to change the http to https in the following? RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.*).html\ HTTP/ RewriteRule .* http://localhost/html/%1 [R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.*)\ HTTP/ RewriteRule .* %1.html [L] – Batty Feb 10 '18 at 17:27

1 Answers1

0

I think I've fixed it with this code from that post, thank you:

RewriteEngine on


RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]

RewriteCond RewriteRule ^ /%1 [NC,L,R]

 RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Batty
  • 1