Forum Moderators: phranque
http://www.example.com/New/privacy-policy.php
http://www.example.com/New/web-hosting.php
http://www.example.com/New/home.php
i'd like to get rid of the .php and replace it with /. so it would look like this:
http://www.example.com/New/privacy-policy/
http://www.example.com/New/web-hosting/
http://www.example.com/New/home/
is that possible? if so how is it done? here is what i was given by someone:
RewriteBase /New/
RewriteRule ^([a-z]+)$ $1/ [R]
RewriteRule ^([a-z]+)/$ /$1\.php
but it doesn't seem to work.
Please help.
Many Thanks In Advance
Cody
To get started, take a look at this recent thread: Cruft Free URLs [webmasterworld.com].
Be aware of two things: First, you must edit your HTML pages --or the script that produces those HTML pages-- so that the ".php" no longer appears in linked URLs on your pages. Then you use mod_rewrite to "re-connect" those URLs, when requested from your server, to the .php script that produces the pages associated with your now-extensionless URL. The process requires two steps, and cannot be correctly done with mod_rewrite alone: Take the ".php" off the links on your pages, then use mod_rewrite to add ".php" back on to the internal filepaths associated with those URLs.
Second, you will need to check for "URL collisions" with existing directories if you use a slash on the end of your new extensionless URLs. So consider whether you really need that trailing slash, and leave it off if not.
Post specific questions back here.
Jim