How do I hide .HTML in a URL?

You can hide the .html file extension in a URL by using URL rewriting . This can be done using server-side scripting languages such as PHP or Apache mod_rewrite module. The process involves mapping clean, user-friendly URLs to the actual URLs that the website uses to retrieve content from a server.

For example, instead of having a URL like: www.example.com/page.html, you could have a URL like www.example.com/page. The URL rewrite rules would then map the clean URL to the actual URL and retrieve the content as if the user had requested the full URL.

Here's an example of how to use Apache mod_rewrite to hide the .html extension in a URL:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ $1 [R=301,L]

This will redirect any requests for .html pages to their equivalent non-.html version and keep the same content intact.

kabeer

Edited  Feb 02, 03:03 am

Article tags

×