我将以下代码添加到我的 CodeIgniter 项目到我的 .htaccess 以删除 index.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]
一切正常。我的网址不再需要 index.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 或允许第三方 cookie 可能会解决此问题。如果没有,则可能是服务器配置问题,而不是您的计算机问题。
注意:客户端 ID 和重定向 URI 已更改为隐私。
我正在使用 PHP SDK 3.1.1 https://github.com/facebook/php-sdk并遵循http://developers.facebook.com/blog/post/503/上的示例代码。当我的 URL 中仍有 index.php 时,一切正常。在我添加重写规则以删除 index.php 后,问题似乎已经开始。
任何想法发生了什么以及如何解决这个问题?