Can not reach admin login page after installation (404 Not Found)


I am new to SilverStripe, but I am trying to solve this issue for a few hours now and have no idea what to do.

Simply, I can’t reach admin login page (after successful installation of SilverStripe on my server). When I click on “CMS” on default page, I’ve got redirected to /silverstripe/public/admin/ on my server but it shows 404 Error with “The requested URL /silverstripe/public/admin/ was not found on this server.”

Can someone please help?

Hi @Viktoria_S, that URL doesn’t look right. Can you try accessing just ‘/admin’ instead?

Thank you for your reply,

Same thing - “The requested URL /admin was not found on this server.”

When I get into directory where “admin” is supposed to be (one from redirect - /silverstripe/public/admin), there is no “admin”, obviously. But I do not know how to redirect it to directory where the admin is as well as I don’t know where the admin is… probably this is something really easy to solve, but I have no idea…

I didn’t really find anyone with same issue with default page.

It sounds like a problem with url rewriting, but you said it installed successfully… There weren’t any warnings when you installed SilverStripe? You may still be available to visit /install.php - can you check there’s no warning about friendly URLs?

Do you have a .htaccess file in the root of your website and does it contain SilverStripe directives?

Actually it sounds like you might have tried to set up a SilverStripe site in a ‘silverstripe’ sub directory within your web root? Ideally you would have a directory for your project (where SilverStripe is installed), and beneath that you would have a ‘public’ sub directory which should be configured to be your web root. But if you can’t do that (i.e. using restrictive/shared hosting) then SilverStripe should be installed directly in to the web root. So directly inside your web root you would end up with directories named ‘app’, ‘vendor’ and ‘assets’.

I am not sure if I understand. Now SilverStripe is installed in /var/www/html/silverstripe/public, but I didn’t choose where I want to install it. How can I choose it? Or what did you mean by installing directory into the web root?

During the installation, I’ve got a message about ‘Friendly URLs are not working…’ but then it installed successfully. Maybe that’s the issue, I don’t know. Do you know how to fix this?

I can show you what .htaccess file contains:

# Deny access to templates (but allow from localhost)
<Files *.ss>
    Order deny,allow
    Deny from all
    Allow from

# Deny access to IIS configuration
<Files web.config>
    Order deny,allow
    Deny from all

# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
    Order allow,deny
    Deny from all

# 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

    RewriteEngine On
    RewriteBase '/silverstripe/public'

    # 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

You’ll need to enable mod_rewrite in Apache for the URLs to work properly.

I’m not sure how the site ended up in ‘/var/www/html/silverstripe/public’ but you could try moving everything out of there and in to ‘/var/www/html/’, including the .htaccess file.

After that you should be able to delete the ‘/var/www/html/silverstripe/’ directory.

That’s assuming that ‘/var/www/html/’ is your web root (it usually is), and that your ‘app’, ‘vendor’ and ‘assets’ folders are inside ‘/var/www/html/silverstripe/public’ currently.

It sounds like you’re installing SilverStripe to a remote server? If you’re just getting started with SilverStripe it’s probably going to be easier to learn if you develop locally. Usually developers will build a website and any updates on their own computer first, and only publish them to a remote server after they’re complete. This ensures you have multiple copies of the website code around for redundancy, and ensures visitors don’t arrive at your website in a half-finished state. If you’re on a Mac, this is a good resource for getting a local development environment set up: macOS 10.14 Mojave Apache Setup: Multiple PHP Versions | Grav

Well, mod_rewrite is enabled. At least, after

a2enmod rewrite

I’ve got

Module rewrite already enabled

And if I move everything into /var/www/html, it is going to continue to redirect it into /silverstripe/public/admin/, isn’t it?

Yes I do, but this is actually part of my homework, I can’t really decide where I will install Silverstripe, it has to be on that server.

Sorry I’m out of ideas :slightly_frowning_face: hard to troubleshoot these issues from outside. It sounds like a server configuration issue rather than a SilverStripe problem but I know that’s not particularly helpful!

No worries, Thank You very much for your help anyway! :slight_smile:

Today, I ran into this issue with Apache’s HTTPd on Linux, too. Had a really hard time but I figured it out: I could not access the /admin site as the rewrite rules within the htaccess file were not working because htaccess files were ignored by default by the server configuration.

According to the server’s documentation, the use of htaccess files is discouraged for performance reasons:

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.

The recommended solution is: Create a directory block in your server’s configuration files and put the contents of the htaccess file there, e. g. if your site is located at /var/www/html/your-site/public:

<Directory "/var/www/html/your-site/public">
# insert the contents of the htaccess file /var/www/html/your-site/public/.htaccess here

…save the file and restart the server.