[英]Symfony project works only homepage. When I navigate to the other pages Apache returns 404
一个有 symfony5 的项目。 当我托管到服务器时,我将默认主机路径从https://example.com更改为https://example.com/public ,因为 index.php 位于 /public 文件夹中。 从那时起,我的网站只能在主页上运行。 当我导航到其他页面时,Apache 返回 404。“在此服务器上找不到请求的 URL /bio/”。 一切都在本地主机上运行,但不在主机上运行。
您应该将 Apache 上的 DocumentRoot 更改为指向公用文件夹,因此,该 url 将指向公用文件夹,而不会出现在您的 url 中。
这是一个 VirtualHost Apache 的示例,它允许您侦听 website.loc url 并指向链接到该网站的公共文件夹(它可能不完整):
<VirtualHost *:80>
DocumentRoot "/path/to/website/public/"
ServerName webiste.loc
DirectoryIndex index.php
ErrorLog "/var/log/httpd/error_log"
CustomLog "/var/log/httpd/access_log" common
<Directory "/path/to/website/public/">
AllowOverride none
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
如果它不起作用,您能否将您的 VirtualHost 在 Apache 上的配置提供给我们? 注意可能存在的敏感信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.