Silverstripe mod_rewrite issue (I think)
Asked Answered
E

2

2

A site I've been working on, which has been working fine on my local dev and live dev environments is giving me issues when I try to deploy it to a live server (the client wants to host it with their existing hosting provider).

I uploaded the site to the server and updated the database config as I have done many times before on both my and other's servers without issue. This time, however, I was presented with:

SilverStripe Framework requires a $databaseConfig defined.

When I removed the .htaccess file from the root folder, the site appeared, however, all the URLs appeared like so:

www.domain.com/index.php/page_name

After a few searches, I came across a solution to the index.php issue; to add the following to my _config file

Director::setBaseURL('/');

I did this and the URL's appeared correctly, however navigating to them would give me a 404.

I reinstated the htaccess file and narrowed it down to this block:

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

When this is in place, I get the database config error mentioned above, when it's not there, my urls produce 404s

Does anyone have any insight as to what can be going on here? I've had a lot of back and forth with the host and he's not very knowledgable and can't offer any advice and I'm no genius when it comes to this side of things.

Ernieernst answered 9/12, 2013 at 16:9 Comment(0)
P
2

I'll assume you are using SilverStripe 3.1+ so the Director config could/should be placed in your YAML config file (the static will be deprecated):

Director:
  alternate_base_url: '/'

Although this helps mainly on issues with base_tag.

The main ModRewrite issue might however be solved by adding a RewriteBase:

RewriteEngine On
RewriteBase '/'

You can use '/' or the folder SS is installed in if not the public root. This is usually automatically handled by the SilverStripe installer by checking $base = dirname($_SERVER['SCRIPT_NAME']); and other little things. Check install.php5 line 1483, you might be able to use this to figure out your RewriteBase.

If that doesn't work, try a fresh install instead of copying to the server your local install.

Pastelki answered 9/12, 2013 at 18:16 Comment(0)
I
1

Do you use a _ss_enviroment.php to define your database config details? I had a similar experience like from in a project i migrated from SS 2.4 to 3.1.2.

Set this in your site _config.php

// Use _ss_environment.php file for configuration
//Please note that your system should have a file, _ss_environment.php, with database connectivity data,
require_once("conf/ConfigureFromEnv.php");

global $database;
$database = '';

I hope this helps

Inguinal answered 10/12, 2013 at 9:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.