1

I can't seem to find an answer online despite trying my best.

I recently set up hosting with StackCP and I have a domain through GoDaddy.

I am trying to remove the .html extension from my links. I want site.com/terms to take you to site.com/terms.html. I've read quite a bit and so far I've tried this

RewriteEngine on Options +MultiViews RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/?$ /$1.html [NC, L] 

I've placed this in my .htaccess file in the root with index.html and the terms.html any help is appreciated.

1 Answer 1

2

Keep this inside the .htaccess file for removing .html extension from the url.

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.html [NC,L] 
Sign up to request clarification or add additional context in comments.

3 Comments

Is this all I need? Because with just that in my .htaccess it doesn't seem to do anything. Do I need to change {REQUEST_FILENAME} to the name of the file?
Actually, it does appear to be working, almost, the issue appears to be that when it redirects to terms.html it's adding a tailing / and that is breaking the link.
Yes no need to do any thing just put the above code in your .htaccess and it will remove the .html extension from the url. to remove trailing / form the url add the below line RewriteRule ^(.*)$ /$1/ [R=301,L] at the end of the above code. Hope it will work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.