You are here: Re: [PHP] Capturing the current URL when mod_rewrite is used « PHP « IT news, forums, messages
Re: [PHP] Capturing the current URL when mod_rewrite is used

Posted by "Richard Lynch" on 01/11/06 19:45

On Wed, January 11, 2006 11:33 am, Brian Dunning wrote:
> How do I capture the current displayed URL when it has been changed
> by mod_rewrite?
> Example:
> original (ugly) URL is
> displayed (friendly) URL is
> When I use 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] that
> only gives me the original URL. How do I get the current URL?

Try using <?php phpinfo();?> in a page with a re-written URL and see
if it outputs the re-written URL.

If that fails, odds are looking pretty bad...

Personally, I have found that not messing with mod_rewrite and using
$_SERVER['PATH_INFO'] with .htaccess instead is far more flexible and

Not to mention portable to servers where you don't (won't) have access
to httpd.conf to enable mod_rewrite.

There is a performance penalty for .htaccess being on, and if you need
to wring out every last microwatt of power from your box, and know for
sure you'll never have to port to a shared environment, then
mod_rewrite is probably the way to go. But for MOST users, it's not.

Back on-topic: If the data you want isn't available, it seems to me
like the kind of thing Apache really ought to be providing for PHP to
give you... Maybe it would be fun for you to dive into Apache source
and submit a patch. :-)

Like Music?



[Reply to this 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

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