1

I have tried to install silverstripe 4.2.1 on two different servers and am getting the same error on install.. I have multiple installations this year on other client machines but this is the first time I have run into this problem. Wondering if it is a 4.2.1 problem

The error message on installation

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

I have placed some garbage text in .htaccess at root, in public_html and in the silverstripe public folder. All three cause a 500 error.

Note that i was able to visit site.com and it redirected to the installer. so I would think that mod_rewrite is indeed enabled.

When I visit site.com it gives the silverstripe version of "Server Error"

My HTAccess file located in the public folder of 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 ###

And the one in public_html

RewriteEngine On
RewriteRule ^(.*)$ public/$1

I am running PHP7.1 on a shared server.

Community
  • 1
  • 1
Daniel H.
  • 422
  • 2
  • 15
  • 2
    It looks like `mod_rewrite` is not enabled on your server. You'll have to enable this in your apache or virtualhost config. According to https://stackoverflow.com/a/9021523/4137738 you can double check this in a little PHP script with `in_array('mod_rewrite', apache_get_modules());` – wmk Sep 18 '18 at 07:13
  • It is 100% enabled – Daniel H. Sep 19 '18 at 23:24

1 Answers1

1

I want to post this here in case someone else runs into this problem. It has plagued me for 4 days now and no one seems to have an answer.

If you install SS on a shared hosting account by either unzipping the source into public_html or by composer you may run into an error on install.

Not able to write friendly urls - check that mod_rewrite is enabled and that AllowOveride is set to All.

I knew that both of those were in fact on after talking to tech support.

When visiting the site after the error on install I would get a server error after some testing could see that the site was indeed rewriting to /public as intended by SS.

Finally I noticed that index.php in /public had permissions of 775. I changed it to 644 and all is well.

Note: I tried installing v4.2.1 on two different hosting providers. BlueHost (has ssh access for composer) and Hostgator(no ssh)Both gave me the same problem

Daniel H.
  • 422
  • 2
  • 15