【发布时间】:2013-01-10 21:55:04
【问题描述】:
我在 codeigniter 中构建了一个简单的 url 缩短应用程序,它还允许用户通过 facebook 登录。
第一次授权时,它在允许 facebook 权限后返回服务器错误。
我已将问题缩小到我的路由文件或我的 htaccess。但无论我怎么尝试,我都无法让它发挥作用。
由于应用程序是 url 更短,任何未指定的路由都使用默认路由。就这样……
$route['login'] = "auth/login";
$route['about'] = "pages/about";
$route['(:any)'] = "redirect/index/$1";
我认为这就是它无法通过身份验证的原因。我试着做:
$route['auth_social/(:any)'] = "auth_social/$1";
这也不起作用。我唯一可以让它工作的时间是如果我将我的 .htaccess 更改为
RewriteEngine on
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)
RewriteRule ^(.*)$ /index.php/$1 [L]
但是我的网址缩短会中断并且不起作用。快把我逼疯了。
有人能看出我哪里出错了吗?
这是我的完整 .htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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
#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]
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
编辑:
这是来自服务器日志的错误:
[10-Jan-2013 11:02:25 UTC] PHP Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user.
thrown in /Users/mycomputer/Documents/grpe/app/application/libraries/facebook/base_facebook.php on line 1058
【问题讨论】:
-
实际错误信息是什么? (检查您服务器的日志文件!)
-
好的。我在osx上使用mamp。我如何找到我的日志文件?
-
这就是我的想法——只是使用 PHP SDK 时未捕获的异常。所以很可能它没有连接到您的路由,而是连接到您的应用程序逻辑。
-
好的,但是当我更改我的 htaccess 文件时,它确实可以工作,但会破坏缩短部分。你有什么建议?
-
可能是 cookie 路径的问题 - 如果 SDK 没有获得所需的 cookie 值,因为它在当前 HTTP 路径下无效,这可能解释了为什么它会在您的路由中失败而不是否则。
标签: facebook .htaccess codeigniter routes