I'm completely new to Craft CMS, I come from the Drupal/Wordpress corner.

On my Ubuntu 20.04 LTS with PHP, MySQL, Apache and Composer installed.

Using Composer I installed craftcms to /var/www/html/testsite/

In /etc/apache2/sites-available/000-default.conf I changed the DocumentRoot to point to /var/www/html/testsite/web

In the browser I point to and I get the Welcome page.

When I click on Go to your control panel I am taken to with the following error:

Not Found The requested URL was not found on this server.

In my /var/www/html/testsite/.env file I have PRIMARY_SITE_URL=http://localhost/testsite/web/

What am I missing? (I have looked at other similar questions here but did not find anything helpful for my specific case).

2 Answers 2


You're close.

The DocumentRoot is where in the filesystem Apache will "start" serving files for that virtual host (server name). Basically it's where the "home page" of the server lives.

So if localhost is the name of the vhost, your "home page" would be at http://localhost and you can get to the admin/dashboard of the site at http://localhost/admin/login.

If for some reason your rewrites aren't working, you can still access the dashboard of the site like http://localhost/index.php?p=admin/login.

The testsite/web isn't part of the URL because that's where in the filesystem Apache will "start" looking but it is part of the DocumentRoot. Basically anything below the root is in the URL and anything above is not accessible.

In your .env file, set your PRIMARY_SITE_URL to http://localhost.

Also see the installation docs.

  • Thanks for this, so I think my rewrites are currently not working because using localhost/index.php?p=admin/login I was able to get to the login form, but after logging in I get taken to which again displays a "Not Found" error (and I have enabled mod_rewrite).
    – BrokenCode
    Jan 24, 2022 at 15:50
  • Make sure you're accessing the site via "localhost" and not the IP Address? Jan 24, 2022 at 15:51
  • Same behavior with "localhost"
    – BrokenCode
    Jan 24, 2022 at 15:56
  • Hmm I may be missing the overwrite directive in the virtual host, let me test that.
    – BrokenCode
    Jan 24, 2022 at 16:02
  • That was it, since I used the default apache 000-default.conf file it was missing the directory specific directives. Working now. Thansk!
    – BrokenCode
    Jan 24, 2022 at 16:04

First you need to enable mod_rewrite in your ubuntu system.

Create new .htaccess file in the root location of your project.

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ web/$1

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php

After this you can see your admin at this location http://localhost/testsite/admin/login

  • Thanks for the suggestion. When you say "root location" do you mean the /web folder of craft cms? Also, since I modified apache DocumentRoot to point to /var/www/html/testsite/web do I still need to point the browser to localhost/testsite/web/admin/login? I would expect that I don't need to do that?
    – BrokenCode
    Jan 24, 2022 at 14:31
  • Not inside web folder you need to create outside of the web folder Jan 25, 2022 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.