Silverstripe安装-友好的URL';它不工作了

Silverstripe安装-友好的URL';它不工作了,silverstripe,silverstripe-4,Silverstripe,Silverstripe 4,我曾尝试在两台不同的服务器上安装silverstripe 4.2.1,但在安装时遇到相同的错误。。今年我在其他客户机上进行了多次安装,但这是我第一次遇到这个问题。想知道这是否是一个4.2.1问题 安装时的错误消息 友好URL不起作用。这很可能是因为站点上未正确配置重写模块。您可能需要让web主机或服务器管理员为您执行以下操作: 您的web服务器上已启用mod_rewrite或其他重写模块 为SilverStripe所在的目录设置AllowOverride All 安装 我在根目录下的.htacc

我曾尝试在两台不同的服务器上安装silverstripe 4.2.1,但在安装时遇到相同的错误。。今年我在其他客户机上进行了多次安装,但这是我第一次遇到这个问题。想知道这是否是一个4.2.1问题

安装时的错误消息

友好URL不起作用。这很可能是因为站点上未正确配置重写模块。您可能需要让web主机或服务器管理员为您执行以下操作:

您的web服务器上已启用mod_rewrite或其他重写模块
为SilverStripe所在的目录设置AllowOverride All 安装

我在根目录下的.htaccess、public_html和silverstripe公用文件夹中放置了一些垃圾文本。这三个都会导致500错误

请注意,我可以访问site.com,它已重定向到安装程序。所以我认为mod_rewrite确实启用了

当我访问site.com时,它给出了silverstripe版本的“服务器错误”

我的HTAccess文件位于SS的公用文件夹中:

    ### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Files>

# Deny access to IIS configuration
<Files web.config>
    Order deny,allow
    Deny from all
</Files>

# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
    Order allow,deny
    Deny from all
</Files>

# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_rewrite.c>

    # Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
    <IfModule mod_dir.c>
        DirectoryIndex disabled
        DirectorySlash On
    </IfModule>

    SetEnv HTTP_MOD_REWRITE On
    RewriteEngine On
    RewriteBase '/public'

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


    # Deny access to potentially sensitive files and folders
    RewriteRule ^vendor(/|$) - [F,L,NC]
    RewriteRule ^\.env - [F,L,NC]
    RewriteRule silverstripe-cache(/|$) - [F,L,NC]
    RewriteRule composer\.(json|lock) - [F,L,NC]
    RewriteRule (error|silverstripe|debug)\.log - [F,L,NC]

    # Process through SilverStripe if no file with the requested name exists.
    # Pass through the original path as a query parameter, and retain the existing parameters.
    # Try finding framework in the vendor folder first
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* index.php
</IfModule>
### SILVERSTRIPE END ###

我正在共享服务器上运行PHP7.1。

我想在这里发布此消息,以防其他人遇到此问题。这已经困扰了我4天了,似乎没有人知道答案

如果您通过将源代码解压为public_html或使用composer在共享主机帐户上安装SS,您可能会在安装时遇到错误

无法写入友好URL-检查mod_rewrite是否已启用,AllowVeride是否设置为All

在与技术支持人员交谈后,我知道这两个项目实际上都已启动

当在安装错误之后访问站点时,我会在一些测试之后得到一个服务器错误,可以看到站点确实按照SS的意图重写为/public

最后我注意到
/public
中的index.php拥有775的权限。我把它改为644,一切正常。


注意:我尝试在两个不同的主机提供商上安装v4.2.1。BlueHost(对composer具有ssh访问权限)和Hostgator(没有ssh)都给了我相同的问题

您的服务器上似乎没有启用
mod_rewrite
。您必须在apache或virtualhost配置中启用此功能。据介绍,您可以在一个小PHP脚本中用数组('mod_rewrite',apache_get_modules())中的
仔细检查这一点已100%启用
RewriteEngine On
RewriteRule ^(.*)$ public/$1