无法访问 Symfony API 路由和获取 Symfony strating 页面
Failed to access Symfony API routes and getting Symfony strating page
我最近切换到 mac,我正在尝试设置 MAMP 环境和基于 Symfony 的 API。
现在的问题是我无法访问路由,我只能得到 Symfony 欢迎页面。
这是我的 httpd-vhosts.conf 文件:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs/syndico-api/public/
ServerName syndico-api.local
ServerAlias www.syndico-api.local
DirectoryIndex /index.php
<Directory /Applications/MAMP/htdocs/syndico-api>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
谢谢!
您的 Directory
指令中缺少 /public
:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs/syndico-api/public
ServerName syndico-api.local
ServerAlias www.syndico-api.local
DirectoryIndex /index.php
<Directory /Applications/MAMP/htdocs/syndico-api/public>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
我刚刚发现我需要在 httpd.config
中添加一个 Alias
Alias /api "/Applications/MAMP/htdocs/syndico-api/public/index.php"
我现在可以通过将 /api 添加到本地地址来访问 api。
谢谢大家!
我最近切换到 mac,我正在尝试设置 MAMP 环境和基于 Symfony 的 API。 现在的问题是我无法访问路由,我只能得到 Symfony 欢迎页面。
这是我的 httpd-vhosts.conf 文件:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs/syndico-api/public/
ServerName syndico-api.local
ServerAlias www.syndico-api.local
DirectoryIndex /index.php
<Directory /Applications/MAMP/htdocs/syndico-api>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
谢谢!
您的 Directory
指令中缺少 /public
:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs/syndico-api/public
ServerName syndico-api.local
ServerAlias www.syndico-api.local
DirectoryIndex /index.php
<Directory /Applications/MAMP/htdocs/syndico-api/public>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
我刚刚发现我需要在 httpd.config
Alias
Alias /api "/Applications/MAMP/htdocs/syndico-api/public/index.php"
我现在可以通过将 /api 添加到本地地址来访问 api。
谢谢大家!