In order to have nice URLs you could use various techniques. But in
case you have a really simple website with pages written in PHP, and
URLs pointing to those PHP files like www.example.com/my-page.php, you
could set nice URLs using .htaccess only. Using following snippet will
let you have URLs like www.example.com/my-page, and still open your
file.
Just use following snippet in order to remove “.php” extension from URL.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
No comments:
Post a Comment