Concealing File Extensions in Website URLs
It's oft-desired to present a more aesthetically pleasing website address by concealing the file extension (such as .php or .jsp). Here's how to achieve this:
Solution:
To remove the file extension from your website's URL, create a file named ".htaccess" in the root directory. Enter the following code within the file:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ .php
Explanation:
Example:
If you access "http://something.example/profile.php" in your web browser, the .htaccess directive will rewrite it to "http://something.example/profile".
The above is the detailed content of How Can I Hide File Extensions (like .php) from My Website URLs?. For more information, please follow other related articles on the PHP Chinese website!