tags:

views:

29

answers:

2

i m using xampp

any project that is saved in htdocs is open in http://localhost/projectname/filename.php

i want that is there any way to do so when i type

http://localhost/projectname/filename and open that page 

means no need to write .php extension in file( by default extension should be php)

A: 

You can create the alias for that.

Sarfraz
how to do it? please elaborate
JustLearn
+1  A: 

You can use mod_rewrite for this. In .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+) $1.php [L]
Ignacio Vazquez-Abrams
when i write above code see what happens`500 Internal Server Error`occurs in current page`Please contact the server administrator, admin@localhost and` `inform them of the time the error occurred`
JustLearn
Then you'll need to edit your httpd config to load mod_rewrite and have `AllowOverride FileInfo`.
Ignacio Vazquez-Abrams
Also, checking the error log will help you figure out what went wrong.
Ignacio Vazquez-Abrams
[Fri Jan 22 19:48:45 2010] [error] [client 127.0.0.1]Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://localhost/project/cms/add_item.php[Fri Jan 22 19:48:45 2010] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.,referer: http://localhost/project/cms/add_item.php
JustLearn
I see now. Answer edited.
Ignacio Vazquez-Abrams
Thanks a Lot Dear, it works...now one last queryif i write something wrong in page name it show `500 Internel server error`but before this htaccess file it shown`404 not found error`
JustLearn
Thanks Buddy, It works..You are Greatone last querybefore this htaccess file, page not found error comes with `404 page not found ` but now`500 Internel Server Error`Occurs ON PAGE NOT FOUND
JustLearn
Change the second line to `RewriteCond %{REQUEST_FILENAME} !.+\.php`.
Ignacio Vazquez-Abrams
now my all CSS and JS is not working bcoz i have been write conditions of js and css on pages ( with .php) but now it's without .php
JustLearn
Okay, then you'll need both `RewriteCond` lines in place, one after the other. Order shouldn't matter.
Ignacio Vazquez-Abrams
Thanx Dear, Thanx a ton
JustLearn