Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts

    .htaccess - RewriteCond problem

    Posted an issue im having in the PHP section before realising im probably having the problems due to my lack of knowledge about the .htaccess file.

    PHP Code:
    php_flag register_globals on

    RewriteEngine  On
    RewriteCond 
    %{REQUEST_FILENAME} !-f
    RewriteRule 
    ^(.*).*$ analyse.php?value=$
    Thats what im currently using, and it wasnt until last night that i realised that i need something to 'capture' the {QUERY_STRING} data too, and i really havent got a clue how to achieve that.

    Im currently using the above to allow virtual folders, analyse $value and display a specific page using the data given, however I hadnt noticed that any variables in the url were basically being destroyed/ignored because of how the page is being processed. The apache pages ive found via google have left me non the wiser on the matter, probably because i dont fully understand it, but i havent seen an example where they've used both, and im pretty sure thats what i need.

    example:
    http://www.mydomain.com/users/
    http://www.mydomain.com/users/paulc2k
    http://www.mydomain.com/users/paulc2k?foo=bar

    At the moment the top 2 work, but if i look for $foo then its empty, its been left behind, and i need to hold onto that data but i dont know how i'd incorporate that into the htaccess file.

    So i have 2 questions...
    1) What is it that i'd need to add to get this to work
    2) Is there anywhere which explains all this to someone who's attempted to understand it but always ends up like the sites ive found on google seem to talk to the visitor like they understand it, i havent found anywhere which talks to me like im a dummy, real entry level understanding but goes beyond entry level aspects, cos thats pretty much my situation right now

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    php_flag register_globals on
    First of all, you shouldn't rely on register_globals as it'll make your code highly insecure. More over, it's deprecated as of PHP 5.3. See http://php.net/manual/en/security.globals.php
    1) What is it that i'd need to add to get this to work
    You could do something like
    PHP Code:
    parse_str($_SERVER['QUERY_STRING'],$query);
    echo 
    $query['foo']; 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    PaulC2K (01-24-2012)

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts
    Yeah, i had a feeling the register_globals wasnt a great idea, although ive no idea what it'd do, or what would be required to remove that and maintain the same functionality but securely.

    I tried your suggestion, but with no success. When i echo the QUERY_STRING it basically brings the virtual folder structure, and stops at the ?foo=bar (or whatever) part, technically its bringing the value=$1 from the analyse.php?value=$1 line in the htaccess file.

    So with a url like: http://www.mydomain.com/users/paulc2k?foo=bar
    i want: $value = paulc2k?foo=bar
    but im getting: $value = paulc2k

    Is there nothing in the htaccess which would allow me to do something like
    PHP Code:
    RewriteRule ^(.*).*$ analyse.php?value=$1&value2=$
    because the first value seems to be working, but i need to to look at the full url not chop part of it off and pretend its not there

  • #4
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts
    I've just found [QSA], hadnt got a clue what it was, but like 99% of my coding - try it, see what it does, if it works then great, if it doesnt try something else randomly picked up on someone elses code via google.

    Actually found it on a post on here, saw it last night and still had it open in the tab, saw someone refer to it as 'Query String Append' and a tiny tiny bulb flickered in my brain

    I really need to look into apache more and understand it, im seeing a few uses for it i would never have known if i hadnt spent hours trying to find a solution to this issue. I guess i should also figure out how to shut down register_globals too


  •  

    Posting Permissions

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