Htaccess tip and tutorial 1


.htaccess files affect the directory in which they are placed and all sub-directories.

Removing Extensions

To remove the .php extension from a PHP file.
For example: yoursite.com/aboutus.php to yoursite.com/aboutus 

you have to add the following code inside the .htaccess file:

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

</IfModule>


Previous
Next Post »
Show Comments: OR