Link to home
Start Free TrialLog in
Avatar of 944media
944media

asked on

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.
Avatar of slyong
slyong

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /$1.php [L]
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 944media

ASKER

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.
RewriteCond %{REQUEST_URI} !\.php$
RewriteCond %{REQUEST_URI} ^/([^/]+)
RewriteRule . %1.php [L]