• I’m planning to do a redirection in my blog and I need to get the URL of the actual page, how can I do that?

    When I’m on mysite.com/wp/index.php I need to get exactly <b>index.php</b>, when I’m on mysite.com/wp/index.php?paged=1 I need to get <b>index.php?paged=1</b>, and also when I’m on mysite.com/wp/?page_id=7 I need to get <b>?page_id=7</b>.

    The redirection code is in the header (header.php) and it is the place where I have to get the URI/URL so my script can work…

    Any help would be appreciated… Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter antoniorojilla

    (@antoniorojilla)

    Ops! I wrote < b > tags instead of < strong >! Sorry!

    Try using PHP’s predefined variable $_SERVER with the ‘REQUEST_URI’ element to call up the current document/query:

    $_SERVER['REQUEST_URI']

    Don’t sweat the <b>’s. You’re not the first to trip over this board’s XHTML-ness. :)

    Thread Starter antoniorojilla

    (@antoniorojilla)

    Thanks for your reply!

    I tried that, but it gave me the full URI/URL. Hopefully I could find the exact element and I solved the problem with this code:

    wp/index.php?<?php echo $_SERVER[‘QUERY_STRING’]; ?>

    I’m new to this and it’s great to see people like you trying to help others! THANKS A LOT FOR YOUR TIME!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to get self URI/URL?’ is closed to new replies.