CodeIgniter + FB PHP SDK + mod rewrite to remove index.php =


CodeIgniter + FB PHP SDK + mod rewrite to remove index.php = disaster

我将以下内容添加到我的 CodeIgniter 项目中,以删除索引.php:

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

一切都很好。我的网址不再需要索引.php在。

但是,这产生了一个有趣的副作用,因此当我尝试使用Facebook OAuth登录时,我收到以下错误:

网页在 =">https://www.facebook.com/dialog/oauth?client_id=123&redirect_uri=http%3A%2F%2Fwww.domain.com%2Fsign_in%2Ffacebook%2F&state=8f3d1e5de60e47935460564a41f35af3&scope=email#= 导致重定向过多。为此清除您的饼干 网站或允许第三方 Cookie 可能会解决问题。如果没有,它 可能是服务器配置问题,而不是您的问题 计算机。

注意:为了保护隐私,客户端 ID 和重定向 URI 已更改。

我正在使用 PHP SDK 3.1.1 https://github.com/facebook/php-sdk 并按照 http://developers.facebook.com/blog/post/503/上的示例代码进行操作。当我的URL中仍然有索引.php时,一切正常。在我添加重写规则以删除索引.php之后,问题似乎已经开始了。

任何想法发生了什么以及如何解决这个问题?

尝试以下补丁:在系统/核心/配置.php文件中,在site_url方法中替换以下行返回 $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;使用新代码:返回 $this->slash_item('base_url').$this->_uri_string($uri).$suffix;

它可能会开始工作...