Build a Real-Time PHP Chat App with MySQL & JavaScript
Learn how to create a real-time PHP chat app using MySQL and JavaScript with user login, typing status, chat history deletion, and a modern, responsive UI.
Suggested:
Learn how to remove .php, .html, and .htm extensions from URLs using .htaccess. Create clean, SEO-friendly URLs on Apache servers with our step-by-step guide.
Want cleaner, more professional-looking URLs for your website? Stripping file extensions like .php, .html, or .htm not only improves SEO and aesthetics, but it also future-proofs your site’s URLs. In this tutorial, we’ll show you how to use .htaccess to hide file extensions from your URLs on Apache servers.
Table of contents [Show]
public_html)..htaccess. If it doesn’t exist, create a new file and name it .htaccess.Important: Make sure your text editor doesn’t save it as .htaccess.txt.
Add the following code at the top of your .htaccess file:
RewriteEngine OnAdd this rewrite rule:
# Remove .php extension
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]Example: https://example.com/about loads about.php
Add these rules below the previous one:
# Remove .html extension
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^/]+)/?$ $1.html [L]
# Remove .htm extension
RewriteCond %{REQUEST_FILENAME}.htm -f
RewriteRule ^([^/]+)/?$ $1.htm [L]Examples:
https://example.com/contact → contact.htmlhttps://example.com/info → info.htmThis will redirect old URLs like about.php to /about using a 301 redirect:
# Redirect .php to extension-less
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
# Redirect .html to extension-less
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R=301,L]
# Redirect .htm to extension-less
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.htm [NC]
RewriteRule ^ %1 [R=301,L]https://yourdomain.com/aboutabout.php, about.html, or about.htm fileAllowOverride All is set in Apache config.mod_rewrite is enabled.Removing file extensions using .htaccess makes your URLs look clean, professional, and SEO-friendly. With just a few lines of code, you can enhance your website's usability and maintainability.
Got Questions?
Drop them in the comments. Happy coding!
Learn how to create a real-time PHP chat app using MySQL and JavaScript with user login, typing status, chat history deletion, and a modern, responsive UI.
A modern PHP-based domain search tool with AJAX, DNS checks, and WHOIS fallback. Get instant domain availability results and smart suggestions in a fast, elegant UI.
Learn how to build an advanced AJAX contact form with PHP that sends email without page reload. Includes modern UI design, form validation, and secure email handling using PHP's mail() function.