NYCPHP Meetup

NYPHP.org

[nycphp-talk] Related to "How to create custom URLs"

tedd tedd at sperling.com
Mon Mar 19 12:28:33 EDT 2007


Hi gang:

I got the idea of how to change things so that if the user types in a 
url to a part of your site, then you can redirect the user to where 
you want.

For example, long ago I had my site setup with folders and indexes. 
For example, one folder was named "contact" with my contact page 
residing inside named as index.php.

For SEO considerations I changed everything to root level. For 
example, the "contact folder index page" combination was changed to 
just contact.php.

However, that left legacy link problems where people/SE's/etc had 
previously linked to my site using the old links.

To solve that problem, I simply used htaccess like so:

RewriteEngine on
RewriteRule ^contact$ contact.php

That meant that anyone who had a link to my previous contact, would 
be redirected to my new contact.php. Everything is cool.

However, I liked the way the url looked before. I liked:

[1] http://sperling.com/contact

instead of the new:

[2] http://sperling.com/contact.php

How can I get the url displayed to look like number [1] regardless if 
the user adds ".php" or not?

In other words, I know how to redirect the user to where I want, I 
just don't know how to change the url the user see's -- how do you do 
that?

Thanks,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list