我正在尝试设置具有某些要求的apache服务器:
对于在根文件夹上的h5ai来说还可以,这是apache配置(httpd.conf):
ServerRoot "/usr/local/opt/httpd"
<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
Listen 8080
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
Listen 80
</IfDefine>
ServerName localhost
<Directory />
AllowOverride All
Require all granted
</Directory>
DocumentRoot "/Users/Pierre-Adrien/Workspace/"
<Directory "/Users/Pierre-Adrien/Workspace/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
DirectoryIndex index.html index.php /_h5ai/public/index.php
在Workspace文件夹下,我有两个Laravel / VueJs网站:site1和site2,它们调用在route / api.php中定义的api。问题是所有这些api调用都出现404错误。
这是我的.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
“ mod_rewrite.so”已激活。
我尝试过virtualHosts
<VirtualHost *:81>
ServerName site1
DocumentRoot "/Users/Pierre-Adrien/Workspace/site1/public"
<Directory "/Users/Pierre-Adrien/Workspace/site1/public">
AllowOverride all
</Directory>
</VirtualHost>
但这不起作用。
我也尝试过这个:
<VirtualHost *:80>
DocumentRoot /Users/Pierre-Adrien/Workspace/site1/public
ServerName localhost/site1/public
</VirtualHost>
==>工作正常,但是我在本地主机上丢失了h5ai ...
谢谢您的帮助!