Forum Moderators: phranque

Message Too Old, No Replies

Making URLs Work Without Suffix

I want http://www.site.com/foo to load http://www.site.com/foo.php

         

kalisti

8:08 am on Nov 7, 2007 (gmt 0)

10+ Year Member



I am trying to make it so that people can enter addresses at my site as just http://www.example.com/foo to get to the php page (similar to how Wikipedia looks), just for aesthetic reasons. I would still like http://www.example.com/foo.php to load appropriately as well.

Right now I am doing it by using:

RewriteEngine on
RewriteRule ^foo$ foo.php [T=application/x-httpd-php]
RewriteRule ^bar$ bar.php [T=application/x-httpd-php]

In the .htaccess file, and just doing a new line for each page. This seems fairly inelegant, as well as adding a fair bit of server load and making me have to edit the .htaccess anytime I add a page. I suspect there is a much easier, more elegant way to do this, but I know absolutely nothing about these things. Any help would be most appreciated.

Thanks!

[edited by: encyclo at 11:07 am (utc) on Nov. 7, 2007]
[edit reason] switched to example.com [/edit]

irldonalb

10:23 am on Nov 7, 2007 (gmt 0)

10+ Year Member



I haven't used mod rewrite in a year or two but I think this should do it.

RewriteEngine on
RewriteRule ^(.*)$ /$1.php

jdMorgan

11:23 am on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A recent thread [webmasterworld.com] on this subject.

Jim