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?
> original (ugly) URL is http://domain.com?id=12345
> displayed (friendly) URL is http://domain.com/California
> 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. :-)
[Reply to this message]