Symfony 4 404 Page not found on all routes except root

大城市里の小女人 提交于 2019-12-13 21:00:58

问题


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


来源:https://stackoverflow.com/questions/48449503/symfony-4-404-page-not-found-on-all-routes-except-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!