Hello folks,
I've been successfully running a silverstripe website for a couple of months, until there was upgrade on the web server. Due to the change on .htaccess file, all the links on my site were modified and appear as http://www.mydomain.com/<subdir>/<page-title>, that is, the subdir where included in the links. At this time, I was able to connect to the Silverstripe on http://www.mydomain.com/<subdir>/admin, but not on http://www.mydomain.com/admin. Now I've fixed the .htaccess file, but I still can't connect to the admin on http://www.mydomain.com/admin. I just return to the login page without any error message. I also found nothing about in the Apache logs.
How can I gain access to the Silverstripe admin?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
In fact the problem occurred because I added the following code in mysite/_config.php.
Director::setBaseURL('http://my.domain.com/');
I solved the issue by replacing this code with
define('RELATIVE_SUBDIR', '<subdir>');
And I modified the method baseURL() in sapphire/core/control/Director.php
static function baseURL() {
if(self::$alternateBaseURL) return self::$alternateBaseURL;
else {
$base = dirname(dirname($_SERVER['SCRIPT_NAME']));
if($base == '/' || $base == '/.' || $base == '\\') $baseURL = '/';
else $baseURL = $base . '/';
// Start custom code
if(defined('RELATIVE_SUBDIR') && substr($baseURL, 0, strlen(RELATIVE_SUBDIR)) == RELATIVE_SUBDIR)
$baseURL = substr($baseURL, strlen(RELATIVE_SUBDIR));
// End custom code
if(defined('BASE_SCRIPT_URL')) return $baseURL . BASE_SCRIPT_URL;
else return $baseURL;
}
}
Now my url's are http://www.mydomain.com/<page-title> and In can access the admin.
I work with SS v2.3.1.
I just installed a fresh copy of SS version 2.3.4. During the installation process I used 'admin' as the user name instead of an email address like it said I could. However, after the installation process, I followed the link to the CMS admin page and used the credentials it suggested. I receive 'I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do so below'
wth?
I tried finding "Director::setBaseURL('http://my.domain.com/');" but it is not even in the file.
per IRC I added "Security::setDefaultAdmin("admin", "password");" in _config,php which allowed my to access the page.
Thanks guys for the quick response!