Rewriting URL (http://www.mysite.com/home/ looks at home.php)

I am using Apache 2.2 on Windows.  I have an URL like this:

http://www.mysite.com/home/

Which I really want to go to home.php.

(There is also http://www.mysite.com/test/ which goes to test.php etc)

I think mod_rewrite may be the solution, however, I have no experience with this.
944mediaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slyongCommented:
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /$1.php [L]
0
ravenplCommented:
The above would work, if You will never have subdirectories. It also may produce infinite loop rewriting self to .php, then again and again

Options +FollowSymLinks
RewriteEngine on
#if the requested file with .php added exists
RewriteCond %{REQUEST_FILENAME} ^(.+?)/?$
RewriteCond %1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
944mediaAuthor Commented:
The recent works well with /home/.

To add a trick to it, there are additional sub directories (i.e. /home/filestructure/) which I still want to go to /home.php.

There is also /contacts/search/  which needs to go to contacts.php and soo on.
0
ravenplCommented:
RewriteCond %{REQUEST_URI} !\.php$
RewriteCond %{REQUEST_URI} ^/([^/]+)
RewriteRule . %1.php [L]
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.