Mobile app version of vmapp.org
Login or Join
Kevin317

: 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

@Kevin317

Posted in: #Cpanel #Domains #Url #UrlRewriting

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!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jessie594

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]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme