【问题标题】:Silverstripe Install - Friendly URL's Not workingSilverstripe 安装 - 友好的 URL 不起作用
【发布时间】:2019-02-21 17:44:39
【问题描述】:

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

安装错误提示

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

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

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

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

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

我的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/$1

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

【问题讨论】:

  • 您的服务器上似乎没有启用mod_rewrite。您必须在 apache 或 virtualhost 配置中启用此功能。根据stackoverflow.com/a/9021523/4137738,您可以使用in_array('mod_rewrite', apache_get_modules());在一个小的PHP脚本中仔细检查这一点
  • 100% 启用

标签: silverstripe silverstripe-4


【解决方案1】:

我想在这里发布这个,以防其他人遇到这个问题。它已经困扰我 4 天了,似乎没有人给出答案。

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

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

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

在安装错误后访问该站点时,经过一些测试可以看到该站点确实按照 SS 的预期重写为 /public。

最后我注意到/public中的index.php权限为775。我将其更改为644,一切正常。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 2012-12-20
    • 2014-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    相关资源
    最近更新 更多