Jump to:

4949 Posts in 13939 Topics by 1489 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » RewriteBase directive in .htaccess and url with spaces

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3242 Views
  • Myrdhin
    Avatar
    Community Member
    67 Posts

    RewriteBase directive in .htaccess and url with spaces Link to this post

    Hello,

    I had a problem with my installation :

    • SilverStripe 2.3.4
    • installation directory : /var/www/my directory/silverstripe-2.3.4/

    The problem was that "install.php" created a .htaccess file with this directive :

    RewriteBase /my directory/silverstripe-2.3.4/

    But, spaces in the url (like in "my directory") isn't supported.

    To resolve the problem, i've changed by :

    RewriteBase /my%20directory/silverstripe-2.3.4/

    If you want, there is the modification to add in the install.php file (in the function createHtaccess, line 875) :

    867: function createHtaccess() {
    868: $start = "### SILVERSTRIPE START ###\n";
    869: $end = "\n### SILVERSTRIPE END ###";
    870:
    871: $base = dirname($_SERVER['SCRIPT_NAME']);
    872: if(defined('DIRECTORY_SEPARATOR')) $base = str_replace(DIRECTORY_SEPARATOR, '/', $base);
    873: else $base = str_replace("\\", '/', $base);
    874:
    ====> 875: $base = str_replace(' ', '%20', $base);
    876:
    877: if($base != '.') $baseClause = "RewriteBase $base\n";
    878: else $baseClause = "";

  • Myrdhin
    Avatar
    Community Member
    67 Posts

    Re: RewriteBase directive in .htaccess and url with spaces Link to this post

    Boooo :'(

    Now i can see my web site but i can't login in the administration interface...

    I think it's a problem with spaces in URL because if i delete spaces (and modify the RewriteBase directive in my .htaccess file to delete spaces in URL), i can login without problem !

    Does Silverstripe have problem with spaces in url ? I think.

  • Myrdhin
    Avatar
    Community Member
    67 Posts

    Re: RewriteBase directive in .htaccess and url with spaces Link to this post

    I think i resolved my problem... But i don't know if it's the best solution because i'm a beginner in SilverStripe php code.

    So, i modified the "sapphire/core/control/Director.php" file, line 417, in "baseURL" method.
    I added this line :

    $baseURL=str_replace(' ', '%20', $baseURL);

    Now, my baseURL method is

    static function baseURL() {
    if(self::$alternateBaseURL) return self::$alternateBaseURL;
    else {
    $base = dirname(dirname($_SERVER['SCRIPT_NAME']));
    if($base == '/' || $base == '/.' || $base == '\\') $baseURL = '/';
    else $baseURL = $base . '/';

    $baseURL=str_replace(' ', '%20', $baseURL);

    if(defined('BASE_SCRIPT_URL')) return $baseURL . BASE_SCRIPT_URL;
    else return $baseURL;
    }
    }

    Now i can login in admin interface.

    3242 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.