【发布时间】:2017-05-24 23:49:36
【问题描述】:
我有一个用 Yii2 在 VPS (Apache 2.4.23) 上开发的网站,结构如下:
user/app (all the sites files and directories)
user/public_html
在 public_html 中有指向目录和文件的链接,例如:
.htaccess (file folder)
admin (file folder)
assets (file folder)
css (file folder)
images (file folder)
index (php file)
psite 有前端和后端,后端在子域上,前端在域上(example.com 和 admin.example.com)
前端使用 http 和 https 加载都很好,而后端不加载资产(css 和图像),后端上的 https 重定向到我不想要的 http。
在错误日志中,我看到一堆(太多无法全部列出)错误,例如以下示例:
[access_compat:error][pid][client]AH01797:client 被服务器拒绝 配置:home/user/app/backend/web/index.php,referer http://admin.example.com/en/user/index
[access_compat:error][pid][client]AH01797:client 被服务器拒绝 配置:home/user/app/backend/web/index.php
[access_compat:error][pid][client]AH01797:client 被服务器拒绝 配置:home/user/app/backend/web/en
前端和后端的 htaccess 文件是相同的,如下所示:
# use mod_rewrite for pretty URL support
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 [L]
# use index.php as index file
DirectoryIndex index.php
我也尝试过(由托管支持建议),但没有成功。
# use mod_rewrite for pretty URL support
RewriteEngine On
# enable symbolic links
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . index.php [L]
# use index.php as index file
DirectoryIndex index.php
能否请您告诉我哪里出了问题以及为什么前端可以正常工作,而后端却不行?
【问题讨论】:
-
你的操作系统是什么?你能分享你的 apache 虚拟主机设置代码吗?
-
CentOS 6 64 位。无论如何问题已经解决了,似乎在 cpanel 设置中,子域只能从 public_html 下的目录提供。