[英]How to access a laravel api in apache virtual host?
I have set up apache virtual host and have a site with below config (the website is working well): NB: The domain names below fictitious.我已经设置了 apache 虚拟主机并有一个配置如下的站点(该网站运行良好): 注意:下面的域名是虚构的。
<VirtualHost *:80>
ServerName www.bill.test.com
ServerAlias bill.test.com
Redirect / https://bill.test.com/
</VirtualHost>
<VirtualHost *:443>
ServerName www.bill.test.com
ServerAlias bill.test.com
DocumentRoot /applications/www/bill.test.com/public_html/public
SSLEngine on
SSLCertificateFile /home/user1/ssl_certificate/test.com/wildcard_eneoapps_com.crt
SSLCertificateKeyFile /home/user1/ssl_certificate/test.com/wildcard_eneoapps_com.key
SSLCertificateChainFile /home/user1/ssl_certificate/test.com/DigiCertCA.crt
ErrorLog /applications/www/bill.test.com/error.log
CustomLog /applications/www/bill.test.com/requests.log combined
<Directory "/applications/www/bill.test.com/public_html/public">
AllowOverride All
</Directory>
</VirtualHost>
Also, on this server I have an API located in the directory below:此外,在此服务器上,我有一个位于以下目录中的 API:
/applications/www/html/ebill-api
Now when I try to call this API in the code, I get the error below:现在,当我尝试在代码中调用此 API 时,出现以下错误:
Client error: `POST http://12.ipp.106.21/ebill-api/public/api/login' resulted in a `404 Not Found` response:\n
My httpd.conf file looks like below:我的 httpd.conf 文件如下所示:
DocumentRoot "/applications/www/html"
#
# Relax access to content within /var/www.
#
<Directory "/applications/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
Please help as I am new to configuring apache and confuse why this doesn't work.请帮助我,因为我是配置 apache 的新手,并不清楚为什么这不起作用。 I was able to call an API on a separate server but I don't understand why calling this one which is on thesame server as the website is not working.我能够在单独的服务器上调用 API,但我不明白为什么调用与网站在同一台服务器上的 API 不起作用。
Since you have the Laravel api in a subfolder, you should adjust the APP_URL in your .env file to be http://12.ipp.106.21/ebill-api/public/
由于您在子文件夹中有 Laravel api,您应该将 .env 文件中的 APP_URL 调整为http://12.ipp.106.21/ebill-api/public/
Try this change.试试这个改变。 See if it help.看看有没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.