Reply to Re: [PHP] Dynamic sub directory listing without redirect

Your name:

Reply:


Posted by Philip Hallstrom on 10/08/05 07:36

> Hi List,
>
> I am trying to allow dynamic URL's for my users to remember similiar to:
>
> www.mysite.com/joesoap
>
> So I want to use "joesoap" in a PHP script to pick up the user's details from
> a MySQL database. If the "joesoap" does not exist in the table
> I will handle that.
>
> So basically I have one file www.mysite.com/index.php which should do all the
> processing.
>
> I have tried with the apache .htaccess mod_rewrite, however when I echo
> $_SERVER['PHP_SELF'] I can't detect the "joesoap". It returns /index.php.
>
> Of course the easiest way is to do something like
> www.mysite.com/index.php?username=joesoap
> but that is too long and complicated for our users. As we have thousands of
> users, I don't want to create actual directories.
>
> Furthermore can this be done too (without a joesoap file):
> www.mysite.com/joesoap?show_extra_details=yes
>
> Any advice/links would be much appreciated. If I am barking up the wrong tree
> throw me a bone please.

If you are using apache, add this to your VirtualHost section for
www.mysite.com:

ForceType application/x-httpd-php
Action application/x-httpd-php /script-to-handle-every-request.php

Then in your document root, put a file named
script-to-handle-every-request.php and do whatever you want.

You'll probably want to start by looking at $_SERVER[PATH_INFO] and go
from there.

I do this to make urls easier to remember for our sales guys so they don't
have to remember that www.mysite.com:8001 is their sales demo site.
Instead they can remember salesdemo.mysite.com/philip and it redirects
them.

good luck!

-philip

[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

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