Silverstripe 安装 - 友好 URL 不工作

Silverstripe Install - Friendly URL's Not working

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

安装时的错误信息

Friendly URLs are not working. This is most likely because a rewrite module isn't configured correctly on your site. You may need to get your web host or server administrator to do this for you:

mod_rewrite or other rewrite module is enabled on your web server
AllowOverride All is set for the directory where SilverStripe is installed

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

请注意,我能够访问 site.com 并将其重定向到安装程序。所以我认为 mod_rewrite 确实已启用。

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

我的 HTAccess 文件位于 SS 的 public 文件夹中:

    ### 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 ###

和 public_html

中的那个
RewriteEngine On
RewriteRule ^(.*)$ public/

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

我想 post 在这里,以防其他人 运行 遇到这个问题。已经困扰我4天了,似乎没有人有答案。

如果您通过将源解压缩到 public_html 或通过作曲家在共享主机帐户上安装 SS,您可能 运行 安装时出错。

无法编写友好的 URL - 检查 mod_rewrite 是否已启用并且 AllowOveride 是否设置为全部。

在与技术支持交谈后,我知道这两个实际上都在运行。

在安装错误后访问该站点时,我会在一些测试发现该站点确实按照 SS 的意图重写为 /public 后收到服务器错误。

最后我发现/public里面的index.php权限是775,我改成644就好了

注意:我尝试在两个不同的托管服务提供商上安装 v4.2.1。 BlueHost(具有作曲家的 ssh 访问权限)和 Hostgator(无 ssh)都给了我同样的问题