如何使用(mod 重写支持)漂亮的 URL 读取 $_GET 变量
各位程序员好,
我第一次使用不错的 URL,但我不太明白为什么我无法从脚本中读取 oAuth 响应.
I'm using nice URLs the first time and I can't quite find out why I can't read my oAuth responses from my script.
这是我的设置:
.htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
我有一个使用 googles oAuth 系统登录用户的脚本.此脚本将用户发送到 google api 页面,在那里他们可以允许我的网站读取他们的电子邮件地址,然后将用户发送回我的网站,并使用许多 $_GET 变量.
I have a script that uses googles oAuth system to log in a user. This script sends the user to the google api page where they can allow my website to read their email adress and then send the user right back to my site with lots of $_GET variables.
我告诉谷歌将它发送到
http://mywebsite/login/google/response
它做到了..
问题是 google 以正常的 GET 格式发送结果,如下所示:
The problem is that google sends the result in the normal GET format like this:
http://mywebsite/login/google/response/?openid.ns=http%3A%2F%2Fspecs.openid.ne[..]
我的脚本无法读取..
当 $_GET 变量与漂亮的 URL 混合时,有没有办法读取它们?
Is there any way to read $_GET variables when they mix with nice URLs?
推荐答案
您需要添加QSA
(查询字符串追加)到您的标志.
You need to add QSA
(query string append) to your flags.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,PT,L]
然后您的 $_GET
将包含正确的值.
Then your $_GET
will contain the correct values.
相关文章