skip to Main Content

I use CloudWays hosting for my web app. I am trying to get my index page to work. Example: www.mysite.com or www.mysite.com to point to my index or home page. I have set up the following controller after running composer require annotations

<?php

namespace AppController;

use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentRoutingAnnotationRoute;

class HomeController extends AbstractController
{

     /**
      * @Route("/", name="main")
      */

    public function index()
    {

        return $this->render('main/index.html.twig', ['controller_name' => 'HomeController',]);

    }
}

I followed the official Symfony 4 documentation for routing which defines this example code(https://symfony.com/doc/4.1/routing.html):

// src/Controller/BlogController.php
namespace AppController;

use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentRoutingAnnotationRoute;

class BlogController extends AbstractController
{
    /**
     * Matches /blog exactly
     *
     * @Route("/blog", name="blog_list")
     */
    public function list()
    {
        // ...
    }
}

My project structure is as follows:

/projectfolder
---- /public_html
     ---- /bin
          /config
          ----/dev
              framework.yaml
          annotations.yaml
          /public
          ----/assets
              /css
              /js
              .htaccess
              index.php
          /src
          ----/Controller
              ----HomeController.php
              Kernal.php
          /templates
          ----/main
              ----index.html.twig
              base.html.twig
          /var
          /vendor
          .env
          .swp
           composer.json
           composer.lock
           symfony.lock

When I enter the url www.mysite.com I get a 403 Forbidden error.

Forbidden
You don't have permission to access this resource.

Apache/2.4.25 (Debian) Server at www.mysite.om Port 80

When I enter the url www.mysite.com/public it works and displays my site perfectly.

How can i fix this issue so my index is at www.mysite.com and not www.mysite.com/public

Google Domains Image:
enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    I figured out what the issue was. In order to fix my issue I needed to do the following:

    Step 1) Navigate to the Cloudways server application settings panel.

    enter image description here

    Step 2) Change webroot to wherever your public files are located in your project.

    enter image description here

    If you do not know where your public files are located you can find out by connecting to the apache server through the provided terminal and using the cd command to navigate to the directory. Or connect with an ftps connection to navigate to the needed directory.

    After doing this www.mysite.com should bring you to your index/home page. After researching as to why this happens I found out that the index.php is one layer down from what my root folder was at first. In order to fix this I needed to bring my root folder to the correct layer where index.php was located.


  2. Since CloudWays seems to be a shared hosting site that uses Apache server you may need an Apache pack. Run command composer require symfony/apache-pack in your console and upload your project files again to see if it helped.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search