You can remove the .html extension from your browser URL by adding a rewrite rule in your .htaccess file.
For example, when viewing yourdomain.com/page your website will serve the contents of yourdomain.com/page.html.
Note: To follow this tutorial you will need your FTP details (these are the same as your cPanel login credentials). If you have forgotten your credentials, they were included in the original Welcome to Serversaurus Hosting email which you should be able to find in your inbox otherwise follow these instructions on how to update your cPanel password.
1. Open your terminal window and ssh onto your hosting server:
ssh username@yourserver.serversaurus.com.au
When prompted, enter your password
2. Change into your public_html directory:
cd public_html
3. Edit the .htaccess file using vi
vi .htaccess
4. Add the following text to the beginning of your .htaccess file, to insert the text firstly type ‘i‘ to enter insert mode, then paste the text below:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
5. To exit insert mode press the esc key then enter :wq to save.
Comments
0 comments
Please sign in to leave a comment.