You are here:
» Implementing Clean-urls?
Implementing Clean-urls?
This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
How do we implement clean-urls in php using .htacces?

1 year 40 weeks ago
Tags:
There are 2 cases we want to use:
1. We want to target to the php extension like this:
http://example.com/home -> http://example.com/home.php
.htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L,QSA]2. We want to target to index.php and add the extension as the GET veriable to index.php. Something like this happens in CMSes like Drupal too.
http://example.com/home -> http://example.com/index.php?q=home
.htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] <code>Post Comment