Jump to content

$_GET stopped working after rewrite


jacko310592

Recommended Posts

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

Link to comment
Share on other sites

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 '?'

Link to comment
Share on other sites

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]

Link to comment
Share on other sites


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 :/

Link to comment
Share on other sites

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/"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.