Symfony 4 404 Page not found on all routes except

2019-08-26 09:20发布

问题:

I have installed symfony 4 on my shared hosting. My structure is like this:

ROOT
  |
  |-- public_html
        |
        |-- tst
  |-- tst
        |
        |-- bin
        |-- config
        |-- src
        |-- translations
        |-- var
        |-- vendor
        |-- composer.json
        |-- composer.lock
        |-- binsymfony.lock

I moved index.php from the public folder to the public_html/tst folder and changed the paths inside that file to match the new structure:

require __DIR__.'/../../tst/vendor/autoload.php';

Now, when running http://mysite/tst, I get the homepage of the site as expected. But when I try another route (other than "/"), I always receive a 404 page not found.

Does this have something to do with privileges of am I missing something?

I figured this one out myself, but if someone tell me how to deploy a Symfony 4 application to a shared hosting, please tell me! I think other people will like this too...

回答1:

You can create symlik for Public. The method you try can lead to problems.

# Enter Directory Root
cd /root_dir

# Create Symlink
ln -s public_html tst/public