tags:

views:

49

answers:

2

Hi All,

I'm new to php and I have created a simple site using php5. my question is

I have a page called login.php , when I type http:///login.php, the page loads

But what I want to do is to load the page without giving the .php extension , as follows

http:///login

Can I do like this, I'm running on apache2 and hoping to publish my site in a shared environment

thanks in advance

cheers sameera

A: 

This can be done with the apache rewrite engine: http://www.ryanbrill.com/archives/cruft-free-urls/

tandu
Your article shows how to rewrite only known pages. My script rewrite all php pages. -1
Alexander.Plutov
+1  A: 

Create .htaccess file in root folder.

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{SCRIPT_FILENAME} !-d
   RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
Alexander.Plutov
Not going to work if there is more than one period in the filename.
tandu
works fine, thanks Plutov
sameera207