Silverstripe 3.x - 所有表单提交都会引发403错误

时间:2014-07-04 15:41:14

标签: silverstripe

我最近将Silverstripe 3站点迁移到新服务器,现在网站上的所有表单提交都会抛出403 Forbidden(nginx)错误。

我已经阅读了这个症状的参考资料,但是找不到任何似乎适用于我的情况的线索,因为它们都没有改变行为。但是,我的网站托管服务商确实建议它可能是.htaccess问题。

站点根目录下的.htaccess文件如下:

### SILVERSTRIPE START ###
<Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Files>

<Files web.config>
    Order deny,allow
    Deny from all
</Files>

# This denies access to all yml files, since developers might include sensitive
# information in them. See the docs for work-arounds to serve some yaml files
<Files ~ "\.ya?ml$">
    Order allow,deny
    Deny from all
</Files>

ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_alias.c>
    RedirectMatch 403 /silverstripe-cache(/|$)
    RedirectMatch 403 /vendor(/|$)
    RedirectMatch 403 /composer\.(json|lock)
</IfModule>

<IfModule mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE On
    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !\.php$
    RewriteRule .* framework/main.php?url=%1 [QSA]

    RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . %1/install.php? [R,L]

</IfModule>
### SILVERSTRIPE END ###

1 个答案:

答案 0 :(得分:0)

您是否在Controller中检查了$ allowed_actions属性。

在SilverStripe 3.1.0中,您需要将$ allowed_actions定义为私有静态

有关详细信息,请参阅以下链接

关于升级的

http://doc.silverstripe.org/framework/en/changelogs/3.1.0(以下信息)

自定义页面类中的静态需要“私有” 需要对每个SilverStripe安装执行操作。

典型错误消息:ErrorPage :: $ db的访问级别必须是公共的

与上述配置更改相关,核心中的许多静态现在都标有私有可见性。虽然PHP允许变量更加可见(例如从“私有”变为“公共”),但如果您尝试限制子类中的可见性,它会抱怨。核心框架从您自己的代码库中的Page类扩展(mysite /),这意味着您需要自己将这些静态更改为私有。相同的规则适用于从Page_Controller继承的控制器。