: How to take off .html from domain.com/page.html I am using cPanel to build a website and I am not sure how to take the .html or .php file extension off my webpages. Usually I will use
I am using cPanel to build a website and I am not sure how to take the .html or .php file extension off my webpages. Usually I will use a python framework and I do the routing manually but I am not sure how to do it with cPanel. I saw something about using .htaccess but I am not sure what I would need to put in there. Any help appreciated!
More posts by @Kevin317
1 Comments
Sorted by latest first Latest Oldest Best
This is how you'd remove the .html extension using a .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ .html
# Replace html with your file extension, eg: php, htm, asp
To add a trailing slash at the end of the URL
(for example: www.example.com/about-us/ to go to www.example.com/about-us.html)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^/]+)/$ .html
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ // [R=301,L]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.