Mod Rewrite and Facebook $_GET variables

人盡茶涼 提交于 2020-01-06 07:31:31

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/14763112/mod-rewrite-and-facebook-get-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!