Results 1 to 4 of 4

Thread: htaccess and php

  1. #1

    Thread Starter
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    htaccess and php

    i have this gallery which has links like this.

    gallery.php?user=205
    205 here is a userid.

    i am using mod_rewrite to have another script decide the userid from this url.

    mysite.com/gallery/someuser

    here "someuser" is username. the script in mod_rewrite is deciding the userid from the username. it's in the database.

    i am using the header() function in the script to get the the gallery.php?user=$id

    now the URL on the browser changes to gallery.php?user=205

    for an example username "someuser" has a userid of 205.
    so when someone visits http://mysite.com/gallery/someuser, mod_rewrite sends it to redirect.php?username=someuser

    then redirect.php finds out the userid from the database and redirects to gallery.php?user=205.

    as the redirect.php is using the header() function to redirect, the browser url changes to gallery.php?user=205.

    is there a way to get around this and the URL in the browser stays the same?

    gallery.php isnt a script of my own and i don't feel like editing it.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: htaccess and php

    If you send a redirect header then the URL in the address bar will change. There is nothing you can do about that. If you want to ensure that this doesn't happen, set the appropriate $_GET variable and then include the gallery.php script.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    Re: htaccess and php

    is there no way to send some variable to an htaccess file?

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: htaccess and php

    You can set an environment variable and provided the server config allows you to read an environment variable from the htaccess file and provided Apache is running as a module. Again however, you don't need to do this, it is counter productive and pointless.

    In an htaccess file you can access an environment variable using the following syntax: %{ENV:VarName}
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width