我正在使用Ubuntu wizzy作为我的本地服务器,然后我在那里设置了域,它们是
- domain.svr
- api.domain.svr
- adm.domain.svr
这就是问题所在。我已经为所有这些创建了完全相同的配置,但为什么只有 adm.domain.svr 不起作用?当我去http://adm.domain.svr/site/dashboard/
时总是响应 404,但当我尝试http://api.domain.svr/site/dashboard/
时没关系
这是我的配置
<VirtualHost *:80>
ServerAdmin localhost@gmail.com
ServerName domain.svr
DocumentRoot /home/shaf/web/domain.dev/frontend/web
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/shaf/web/domain.dev/frontend/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin localhost@gmail.com
ServerName adm.domain.svr
DocumentRoot /home/shaf/web/domain.dev/backend/web
<Directory /home/shaf/web/domain.dev/backend/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-adm-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-adm-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin localhost@gmail.com
ServerName api.domain.svr
DocumentRoot /home/shaf/web/domain.dev/api/web
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/shaf/web/domain.dev/api/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-api-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-api-access.log combined
</VirtualHost>
这是我的.htaccess,我将其放置在每个域Web文件夹中
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
请给我建议,我真的不知道。
您的ServerName domain.svr是错误的。Apache无法路由它。尝试将其重命名为 adm.domain.svr
我只是通过将另一个目录复制到 adm 并尝试但失败来解决这个问题,所以我创建了另一个 1 个主机,所以我有 4 个主机。 1 对于 adm 来说是重复的,它工作得很好。我仍然不知道发生了什么,但似乎只有那个文件夹没有读取 htaccess,我确信这一点,因为我已经尝试交换子域,但只有 adm 文件夹不读取 htaccess 文件。
所以这是我的结论,我不知道这是否正确,但 apache 有 htaccess 缓存,所以我需要硬刷新 apache(只有重新启动 apache 不起作用,因为我已经尝试了几次并且没有任何反应)所以也许你需要重新启动你的操作系统/服务器,如果你不想要它, 试试我的方式。