1

I'm new with Symfony (5.3) and i'm trying to use the EasyAdmin^3 package and its controller.

class DashboardController extends AbstractDashboardController
{
    /**
     * @Route("/admin", name="admin")
     */
    public function index(): Response
    {
        //return parent::index();
        $routeBuilder = $this->get(AdminUrlGenerator::class);
        $url = $routeBuilder->setController(BookCrudController::class)->generateUrl();
        return $this->redirect($url);
    }

    public function configureDashboard(): Dashboard
    {
     ...
    }
    ....

In security.yaml, there is no access control:

access_control:
        # - { path: ^/admin, roles: ROLE_ADMIN }

I tried on my computer with

>symfony server:start -d
>symfony open:local

The URL http://127.0.0.1:8000/admin works

But on my server https://subdomain.domain.com/admin it doesn't work (error 404). But the route is configuring:

>php bin/console debug:router
admin                      ANY      ANY      ANY                             /admin

1
  • Unless you did something extra special, Symfony doesn’t care about domains, subdomains, IPs or even ports, so your problem is probably elsewhere. Do you have debug enabled on the server? Commented Nov 27, 2021 at 4:38

1 Answer 1

1

the URL to wasn't redirected to /public/ I added in / directory .htaccess file

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^(.*)$ public/index.php?$1 [L,QSA]

and added .htaccess in /public/

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

And then the /admin was forbidden, then I added in DashboardController file / function configureDashboard()

return Dashboard::new()
          ->disableUrlSignatures()
          ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.