For some reason I can no longer go to my default site URL while I am logged in.

Going to http://localhost:3001/craft-site/web/ gives me the following message in Chrome:


Trying to refresh the site gives me this strange error message from Craft:

HTTP 404 – Not Found – yii\web\NotFoundHttpException


I can still go to http://localhost:3001/craft-site/web/index while logged in and it works fine. The most interesting thing is that the file index.twig is completely empty.

  • What is the value that you've set in your .env for DEFAULT_SITE_URL?
    – Campiotti
    Dec 9, 2019 at 13:13
  • .env says DEFAULT_SITE_URL="http://localhost:3001/craft-site/web"
    – PWL
    Dec 9, 2019 at 13:15
  • 1. What are you using to run your local server (Apache, Nginx, PHP, etc...)? 2. What happens when you try and access the Control Panel (config/general.php's cpTrigger value) in your browser: A. with index in your URL. B. without index in your URL? I'm thinking you might have some config stuff that's broken since the craft error is saying Template not found: $DEFAULT_SITE_URL/$DEFAULT_SITE_URL which makes sense as you wouldn't have the entire webserver address as a file/template on your system...
    – Campiotti
    Dec 9, 2019 at 13:22
  • Tried to undo my last steps and I found 'loginPath' => '/' in my config\general.php. I did that because the front page has the login. For some reason it was not a good idea to set that to the root URL. Removed this line and it is now working again.
    – PWL
    Dec 9, 2019 at 13:26
  • Oh by the way could you either write your own answer and mark it or mark my answer as "the answer"/"the solution" so this question doesn't remain marked as "unanswered" and instead be marked as "solved"? This will help others facing similar issues when they find your question as they'll be aware that there was a solution found with your issue. Thanks!
    – Campiotti
    Dec 10, 2019 at 13:23

1 Answer 1


For Documentation out of the comments:

'loginPath' => '/' was present in config/general.php, after removal of this line the website started working again.


Don't set the Admin Backend or any other type of URL which requires a login (or is special in any way really) to "/" or an empty string, this can and will very likely cause major issues such as a completely non-functioning site unless index.php is in the URL (at all times).


I once faced a similar issue, the cpTrigger in config/general.php to an inexistant .env variable, eg $cpTr1gger, but since that wasn't present in my .env and I used getenv('cpTrigger') which returns empty strings if the requested var isn't found, it completely broke my website, similar to the above mentioned issue, it only worked with index.php in the URL.

Your Answer

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

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