SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2004
    Location
    Los Angeles
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rewrite & environment variables

    Ok, I've searched the forums but haven't found anything. If my question has already been answered, feel free to link me


    Here is my current (edited) htaccess file:
    Code:
    DocumentRoot [...]
    ServerName [...]
    Options All
    <Location "/">
    RewriteEngine On
    RewriteRule news/([0-9]+)_(.+)\.html comments.php?date=$1&tag=$2 [QSA]
    </Location>
    As you can see, that rewrites /news/20040412_newsstory.html to /comments.php?date=20040412&tag=newsstory. It works perfectly except for one thing.

    I want to be able to use $_SERVER['PHP_SELF'] and other environment variables but they refer to the actual name of the script (comments.php). How can I set it up so PHP_SELF and others refer to /news/20040412_newsstory.html?

    Thanks.

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    first of all the rules you wrote are located into an httpd.conf because the Location directive can be used only within httpd.conf

    The answer to your problem is this:
    Do not use $_SERVER['PHP_SELF'] but use $_SERVER['REQUEST_URI']


    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03


Bookmarks

Posting Permissions

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