背景
我的网络服务器上有一个apache配置文件,它有一个路由地址,然后定义了一些别名。我遇到的问题是,在404的情况下,即使使用别名门户,用户也会被重定向到根站点,查看配置文件是有意义的。
问题
如何为每个别名定义ErrorDocument设置?
源代码
<VirtualHost *:80>
ServerAlias *.samplesite.mysite.mycompany.co.uk
UseCanonicalName Off
ErrorDocument 404 /404.html
DocumentRoot /var/www/html/mysite1
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript text/javascript application/json
Alias /mysite2 /var/www/html/mysite2
Alias /mysite3 /var/www/html/mysite3
Alias /mysite4 /var/www/html/mysite4
<Directory "/var/www/html/mysite1">
Require all granted
Options +Indexes
</Directory>
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/mysite_access_log vcommon
LogLevel info
#LogLevel debug rewrite:trace6
ErrorLog "logs/mysite-error.log"
</VirtualHost>
答案 0 :(得分:1)
好的,所以我找到了答案,发布的内容只是对其他人有用:
Alias /mysite2 /var/www/html/mysite2
<Directory "/var/www/html/mysite2">
ErrorDocument 404 /mysite2/404.html
Require all granted
Options +Indexes
</Directory>
Alias /mysite3 /var/www/html/mysite3
<Directory "/var/www/html/mysite3">
ErrorDocument 404 /mysite3/404.html
Require all granted
Options +Indexes
</Directory>
Alias /mysite4 /var/www/html/mysite4
<Directory "/var/www/html/mysite4">
ErrorDocument 404 /mysite4/404.html
Require all granted
Options +Indexes
</Directory>