Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2012, 09:35 AM   PM User | #1
PaulC2K
Regular Coder

 
Join Date: Jul 2005
Posts: 110
Thanks: 13
Thanked 0 Times in 0 Posts
PaulC2K is an unknown quantity at this point
.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
PaulC2K is offline   Reply With Quote
Old 01-24-2012, 10:51 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
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
Quote:
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']; 
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
PaulC2K (01-24-2012)
Old 01-24-2012, 11:22 AM   PM User | #3
PaulC2K
Regular Coder

 
Join Date: Jul 2005
Posts: 110
Thanks: 13
Thanked 0 Times in 0 Posts
PaulC2K is an unknown quantity at this point
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
PaulC2K is offline   Reply With Quote
Old 01-24-2012, 11:32 AM   PM User | #4
PaulC2K
Regular Coder

 
Join Date: Jul 2005
Posts: 110
Thanks: 13
Thanked 0 Times in 0 Posts
PaulC2K is an unknown quantity at this point
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
PaulC2K is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:17 AM.


Advertisement
Log in to turn off these ads.