htaccess从url中删除特定的get参数

问题描述 投票:0回答:1

我正在使用Google OAuth连接到信息中心,问题是当回调的GET &scope参数包含类似“https://www.googleapis.com/auth/userinfo.profile”的网址时,主机会返回错误403。

因此,经过多次研究,我发现的唯一解决方案是从网址中删除范围。

我想更改回调网址:

https://msite.com/?code=xxx&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email

对此

https://msite.com/?code=xxx&scope=true

这是我的基本htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?a=$1 [QSA,L]
apache .htaccess google-authentication
1个回答
0
投票

你可以用这个:

RewriteEngine on

RewriteCond %{THE_REQUEST} /\?code=([^&]+)&scope=email.+ [NC]
RewriteRule ^$ /?code=%1&scope=true [L,R=301]

这将重定向您的网址

/?code=Sometext&scope=emailSometext

/?code=Sometext&scope=true
© www.soinside.com 2019 - 2024. All rights reserved.