Login Register


Removing file extensions using htaccess filter_list
Author
Message
Removing file extensions using htaccess #1
Simple tutorial to remove annoying extensions from your URL, makes everything more user and search engine friendly. Gotta show your URLs some love, don't force them to have those god damn ugly extensions!!

Everything I mention in this tutorial goes in a new file named .htaccess which should be placed in your root folder.

Code:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php

The code above removes .php and .html extensions, you can copy the entire code and paste it in again changing the values to remove any kind of extensions.

Code:
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L]

The code above adds a trailing slash after the URL, so aboutus.php would become aboutus/ - w00t.

Short and sweet. Just remember you will need to change all of your affected URLs to remove the extensions.

Reply







Users browsing this thread: 1 Guest(s)