[英]Is it possible to set ErrorDocument in Apache httpd for defined alias?
Background: 背景:
I have an apache configuration file on my webserver and it has a route address and then a number of alias' defined. 我的网络服务器上有一个apache配置文件,它有一个路由地址,然后定义了多个别名。 The issue i have is that in the event of a 404 the user is re-directed to the root site even when using the alias portal, which looking at the configuration file makes sense. 我遇到的问题是,在使用404的情况下,即使使用别名门户网站,用户也被重新定向到根站点,这在配置文件中很有意义。
Question 题
How can i define the ErrorDocument settings for each of my aliases? 如何为每个别名定义ErrorDocument设置?
Source Code 源代码
<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>
ok so i found the answer, will post just incase its useful to anyone else: 好的,所以我找到了答案,以防万一它对其他人有用:
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.