Hiding file extensions


#1

Hi I want to hide the .php file extensions on my website, they are ugly.

I created a .htaccess file using code form the wiki that is supposed to do the job:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /$1.php [L,QSA]

I uploaded the file as ASCII not binary, following the instructions. No word wrap in the original text file. The file is in my root dir as are all the php files. All of the php extensions still show.

Can anyone suggest what I may be doing wrong?


#2

[quote]Hi I want to hide the .php file extensions on my website, they are ugly.

I uploaded the file as ASCII not binary, following the instructions. No word wrap in the original text file. The file is in my root dir as are all the php files. All of the php extensions still show.[/quote]
That code is not meant for “hiding extensions”. Technically what it does it manipulate the requested URL and then acts on the result of this manipulation. The result has to be a valid URL.

So in the end /test and /test.php will both be valid and bring up the same web page.

The “hiding” part comes into play when you tell people what URL you want them to use. Edit your HTML an drop the extension.

:cool: openvein.org -//-


#3

Thanks very much for the explanation. It works the way you say. :slight_smile: