【问题标题】:htaccess remove specific get parameter from urlhtaccess 从 url 中删除特定的 get 参数
【发布时间】:2019-03-11 11:53:40
【问题描述】:

我正在使用Google OAuth连接仪表板,问题是当回调的GET&scope参数包含像“https://www.googleapis.com/auth/userinfo.profile”这样的URL时,主机返回错误403。

因此,经过多次研究,我发现的唯一解决方案是从 url 中删除 scope

我想从这里更改回调 url:

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】:

    你可以用这个:

    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
    

    【讨论】:

      猜你喜欢
      • 2017-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      • 1970-01-01
      • 2014-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多