SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    va
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod_rewrite and url variables

    I know there've been a lot of posts on mod_rewrite, and yeah, i've read through a lot of them. anyways, i've got a bunch of questions.

    i'm trying to change a url address like "page/1" to "page.php?id=1". and this is what i placed in my .htaccess file.

    RewriteEngine on
    RewriteRule ^page/([0-9]+)/?$ page.php?id=$1 [L]

    ok, it works fine. question is, when i try to output $id or $_GET['id'], nothing shows up. i figured a workaround this problem would be to get the url address, 'explode' it and get the url variables from that. but i thought that since page/1 is actually page.php?id=1, the url variables are still kept??? (when i type in page.php?id=1 and output $id, it works fine, not page/1).

    my second problem is this. when i deleted the htaccess file, it still does the mod_rewrite! i've tried logging in with a telnet ssh client to delete it, but there's no such file. when i try to upload another htaccess file in the same directory with say another mod_rewrite command such as:
    RewriteRule ^test/([0-9]+)/?$ page.php?id=$1 [L]

    test/1 will not pick up page.php?id=1! but if i add a new page, say
    RewriteRule ^test/([0-9]+)/?$ test.php?id=$1 [L]

    test/1 start working. but then it won't stop working when i delete the htaccess file. what's wrong? is it cached in a file somewhere???

    by the way, i do not have access the apache config file since i'm on a shared server.
    Thanks for all your help

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    va
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    > bump <

  3. #3
    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)
    I had a similar tricky issue in the past and as far as I remember the solution is:

    Please put this line at the top of your .htaccess :

    Options -MultiViews




    p.s.
    That option is responsible of converting /pippo to /pippo.php, so we should turn it off..
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  4. #4
    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)
    Does it work ?
    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
  •