Hiding file extensions

Hiding file extensions

Posted by: Potatis
Posted on: 2009-05-07 23:46:00

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?



Re: Hiding file extensions

Posted by: Atropos7
Posted on: 2009-05-08 22:58:00

In reply to:

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.


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 -//-

Re: Hiding file extensions

Posted by: Potatis
Posted on: 2009-05-13 22:36:00

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

Tags: php extensionsrewriterulefile extensionsphp filehtaccess fileasciiwikirewritecondjob