Reply to Re: seeking mod_rewrite solution

Your name:

Reply:


Posted by Chung Leong on 03/02/06 05:02

joelbyrd@gmail.com wrote:
> I have a people-networking type site in which each user has their own
> profile page, with their user id encoded. So, for example, the web
> address of their page might look like
> "www.example.com/my_profile.php?user_id=fdjkhfh2489298hf298h3s0dhfxj".
> I want the users to be able to choose their own web address that would
> look like "www.example.com/Joel", and then when they type in that
> address, they are automatically redirected to their profile page with
> the more complex address.
>
> I believe mod_rewrite is the solution to this?

Yes, it is.

> Reading a little bit about mod_rewrite, I believe the rule I want is
> something like the following:
>
> RewriteRule ^/(.*) /redirect_user.php?user_name=$1

No, that wouldn't work too well, as it redirect every request to the
script. In general you want your rewrite rules to be as narrow as you
can make them. The pattern ^/\w+\/?/$ probably makes more sense.

I would also modify my_profile.php so it finds the user based on the
user name instead of doing a redirect to the page with the user id.
Don't really see a reason to do it in two steps.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация