SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2006
    0 Post(s)
    0 Thread(s)

    PHP_SELF and REQUEST_URI alternative

    I have a rewrite rule e.g. 'info.php?page=1' for 'info/page1/'

    However aside from hardcoding (which I can't as it's used on multiple pages) I can't work out what to put in the href. Here is a snippet of code:

    echo( "<a href='{$_SERVER['REQUEST_URI']}/page$i'>$i</a>");
    But REQUEST_URI will give me 'info/page1/page2' if I click on page 2 from 1 and 'info/page1/page2/page1' if I click back to page 1.

    PHP_SELF will display the actual script i.e. info.php?page=1.

    Is there anything else I could use?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    0 Post(s)
    0 Thread(s)
    your urls no longer map to your filesystem, because you are using mod rewrite.

    you wrote the rules to map a url to a given filename and paramaters. now you should write some rules in your php script to map a given filename and parameters back into a url. make a function.

    there is a chance that using dirname() on the request uri will work for your seemingly simple url mapping.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts