If you want to remove the .html extension from your website URLs to make them cleaner and more user-friendly, you can do so using the .htaccess file on an Apache server.
Here are the steps:
- Access your ‘.htaccess’ file:
- Log in to cPanel.
- Open “File Manager” under “Files” section.
- Navigate to Your Website’s Root directory, that is “public_html” folder.
- If there is no .htaccess file, you can create one by clicking “+File” and naming it .htaccess.
- Edit the .htaccess file:
- Open the .htaccess file: Right-click on the .htaccess file and select Edit.
- Add Rewrite Rules: Insert the following code at the end of the file:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html [NC,L]
This code tells the server to serve the .html file even if the .html extension is not stated in the URL.
- Click “Save Changes” and then “Close” to apply the changes.
- Verify the changes:
- Test your URLs:
- Open a web browser and navigate to your website.
- Try accessing a page without the .html extension to ensure it loads correctly.
- Check for Errors: Ensure that all your pages are accessible and that there are no 404 errors.
- Test your URLs:
- Additional Tips:
- Before making any changes, it is a good idea to download a copy of your original .htaccess file for backup.
- If you don’t see the changes immediately, try clearing your browser cache or using a different browser.
By following these simple steps, you can remove the .html extension from your URLs, making them cleaner and easier to remember. For extra assistance, seek help from our support specialists.
For detailed instructions on modifying your .htaccess file, see our guide on How to Edit the Existing .htaccess File.