I am designing a website. I want my website address to look like the following image:
I don't want my website to look like http://something.com/profile.php
.
I want the .php
extension to be removed in the address bar when someone opens my website. In other words, I want my website to be like: http://something.com/profile
As a second example, you can look at the Stack Overflow website address itself.
How can I get this done?
Just add an .htaccess file to the root folder of your site (for example, /home/domains/domain.com/htdocs/) with the following content:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
More about how this works in these pages: mod_rewrite guide (introduction, using it), reference documentation