How to read $_GET variables with (mod rewrite powered) nice URLs

北慕城南 提交于 2019-12-04 03:37:53

问题


Hello fellow programmers,

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.

So this is my setup:

.htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

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.

I tell google to send it to

http://mywebsite/login/google/response

and it does that..

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[..]

and my script can't read it..

Is there any way to read $_GET variables when they mix with nice URLs?


回答1:


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]

Then your $_GET will contain the correct values.



来源:https://stackoverflow.com/questions/10555589/how-to-read-get-variables-with-mod-rewrite-powered-nice-urls

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