jacko310592 Posted May 11, 2010 Share Posted May 11, 2010 hey guys i have this rewrite code: RewriteRule ^(.+)/pictures/(.+)?$ profile/pictures.php?$1 [NC,L] which rewrites "mysite.com/profile/pictures.php" to "mysite.com/USER/pictures/ID/" but a problem i have just found with it is that i need to be able to use a get vairable for a current page number, so the url would be like: "mysite.com/USER/pictures/ID/?page=1" but its no longer getting any get variables (in php) can anyone suggest how this can be solved, thanks Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/ Share on other sites More sharing options...
cags Posted May 11, 2010 Share Posted May 11, 2010 Add the QSA flag in with the NC and L flags. Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1056822 Share on other sites More sharing options...
jacko310592 Posted May 11, 2010 Author Share Posted May 11, 2010 thanks for the reply cags. i gave that a go, but still no luck :/ anymore ideas? Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1056823 Share on other sites More sharing options...
cags Posted May 12, 2010 Share Posted May 12, 2010 No, because that solution works. Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1057008 Share on other sites More sharing options...
jacko310592 Posted May 12, 2010 Author Share Posted May 12, 2010 hmm, how strange. with the rewite rule being.. RewriteRule ^(.+)/pictures/(.+)?$ profile/pictures.php?$1 [NC,L,QSA] and php code being $_GET['page'] and the URL of mysite.com/USER/pictures/ID/?page=2 gives me nothing in the output (output being the echo of the GET) are there any settings/code im missing to recognise variables after the '?' Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1057162 Share on other sites More sharing options...
cags Posted May 12, 2010 Share Posted May 12, 2010 It's perhaps because your current pattern is malformed. A query_string should consist of key/value pairs. In your RewriteRule you are moving the first folder name to the query_string, but is this supposed to be a key or a pair? RewriteRule ^(.+)/pictures/(.+)?$ profile/pictures.php?something=$1 [NC,QSA,L] # or RewriteRule ^(.+)/pictures/(.+)?$ profile/pictures.php?$1=something [NC,QSA,L] Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1057171 Share on other sites More sharing options...
jacko310592 Posted May 12, 2010 Author Share Posted May 12, 2010 erm, im not too sure what you mean, sorry. when i tried the following rewrite code: RewriteRule ^(.+)/pictures/(.+)?$ profile/pictures.php?user=$1&id=$2&page=$3 [NC,QSA,L] i got these results when using echo on the GET variables: $_GET[user] >> profile/index.php $_GET[id] >> 150/ $_GET >> (Blank) that was when using this URL http://localhost/jacko310592/pictures/150/?page=1 so my pattern must be malformed, i just dont see how :/ Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1057190 Share on other sites More sharing options...
jacko310592 Posted May 12, 2010 Author Share Posted May 12, 2010 oh, just removed a piece of code (earlier on in my htaccess) and it works fine now, but what with the following code was casuing this problem? RewriteRule ^(.+)/?$ profile/index.php?$1 [NC] thanks again cags, and sorry i hadnt tried this earlier EDIT: the above code is to rewrite "mysite.com/profile/index.php" to "mysite.com/USER/" Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1057193 Share on other sites More sharing options...
jacko310592 Posted May 12, 2010 Author Share Posted May 12, 2010 ahh, the above code also needs the 'QSA', silly me! again, thanks so much cags- i really appreciate you helping me Quote Link to comment https://forums.phpfreaks.com/topic/201425-_get-stopped-working-after-rewrite/#findComment-1057196 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.