iRector
iRector

Reputation: 1984

Mod Rewrite and Facebook $_GET variables

While writing my login system, I came across a little issue when authorizing an user with Facebook...

After someone clicks the 'Login with Facebook' button and signs in/authorizes my app, Facebook redirects back to my site, with a series of $_GET variables, as normal. The only issue is I'd like to check if one of those variables are set in order to check the status of the Facebook login.

When I try pulling the $_GET var, it 'says' it doesn't exist. The issue is with my using mod_rewrite to clean up the apparence of my url:

#RewriteRule ^([A-Za-z0-9]+)/?$ ?a=b&content=$1 [L]
#RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/?$ ?a=b&content=$1&page=$2 [L]

This turns:
www.mysite.com?content=login&page=2 into
www.mysite.com/login/2

So my url of www.mysite.com/content?state=[...]&code=[...]&...etc must be confusing the variables Facebook assigns, with the to be rewritten $_GET vars.

Same thing happens with a url with both the content and page set. eg: www.mysite.com/content/page?state=......

What would be the best way of solving this? I know I could find another way to show a confirmed Facebook login, but this will continue to be an issue for other situations in the future, I'm sure.

Thanks in advance.

Upvotes: 0

Views: 210

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324840

Try using [L,QSA] instead of just [L].

Upvotes: 1

Related Questions