Apache 2.4 ErrorDocument for multiple subdomainsTomcat cookies not working via my ProxyPass VirtualHostApache...
Did arcade monitors have same pixel aspect ratio as TV sets?
How could a planet have erratic days?
Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?
When were female captains banned from Starfleet?
Angel of Condemnation - Exile creature with second ability
Multiplicative persistence
How does the math work for Perception checks?
How to rewrite equation of hyperbola in standard form
Add big quotation marks inside my colorbox
How do you make your own symbol when Detexify fails?
Temporarily disable WLAN internet access for children, but allow it for adults
What does "Scientists rise up against statistical significance" mean? (Comment in Nature)
Why is it that I can sometimes guess the next note?
Does the UK parliament need to pass secondary legislation to accept the Article 50 extension
How should I respond when I lied about my education and the company finds out through background check?
Using substitution ciphers to generate new alphabets in a novel
Has any country ever had 2 former presidents in jail simultaneously?
Can a stoichiometric mixture of oxygen and methane exist as a liquid at standard pressure and some (low) temperature?
What is the evidence for the "tyranny of the majority problem" in a direct democracy context?
What if a revenant (monster) gains fire resistance?
How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?
Why is this estimator biased?
Keeping a ball lost forever
PTIJ: Haman's bad computer
Apache 2.4 ErrorDocument for multiple subdomains
Tomcat cookies not working via my ProxyPass VirtualHostApache Virtual Hosts Not Workingapache httpd.conf - virtualhost configurationApache not accessing a symlink vhost directory?Apache Virtual host (SSL) Doc Root issueApache vhost for subdomain redirects to rootapache: absolute ErrorDocument relative /var/www/?ServerAlias without www not working on SSL virtualhostMy virtual hosts file for my subdomain is not being picked upApache 2.4 using default DocumentRoot instead of VirtualHost DocumentRoot
we're running a large project for different customers, each has its own subdomain. Apache should not execute any script if an invalid subdomain is used. Instead, an error page should be shown.
Working:
this is out zzz-default.conf which is the last VHOST and matches all queries that are not catched by another VHOST.
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
Redirect 404 /
DocumentRoot /var/www/html/
ErrorDocument 404 "This Subdomain does not exist."
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What's not working:
ErrorDocument 404 /404.html
This file is located in /var/www/html/
and contains pure html, no scripts.
Our problem seems to be the redirect rule, but we need this to match all subdomains and rewrite to /
.
If I enable this and call an invalid subdomain, I get
Not Found
The requested URL / was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Anybody knows why?
Edit:
The other VHOSTs are defined as
<VirtualHost *:80>
ServerName client.project.example.com
Header always append X-Frame-Options SAMEORIGIN
</VirtualHost>
Include /path/to/local/client/httpd-vufind.conf
There are 13 VHOSTs defined like this and then the above zzz-default.conf
is loaded.
virtualhost errordocument
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
we're running a large project for different customers, each has its own subdomain. Apache should not execute any script if an invalid subdomain is used. Instead, an error page should be shown.
Working:
this is out zzz-default.conf which is the last VHOST and matches all queries that are not catched by another VHOST.
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
Redirect 404 /
DocumentRoot /var/www/html/
ErrorDocument 404 "This Subdomain does not exist."
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What's not working:
ErrorDocument 404 /404.html
This file is located in /var/www/html/
and contains pure html, no scripts.
Our problem seems to be the redirect rule, but we need this to match all subdomains and rewrite to /
.
If I enable this and call an invalid subdomain, I get
Not Found
The requested URL / was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Anybody knows why?
Edit:
The other VHOSTs are defined as
<VirtualHost *:80>
ServerName client.project.example.com
Header always append X-Frame-Options SAMEORIGIN
</VirtualHost>
Include /path/to/local/client/httpd-vufind.conf
There are 13 VHOSTs defined like this and then the above zzz-default.conf
is loaded.
virtualhost errordocument
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Check error_log for hints, it will show you which file it's trying to locate for /404.html
– serverliving.com
May 9 '16 at 7:15
No. There is no entry since apache restart. There's only oneerror.log
file. It does not get logged. Inaccess.log
, I see the 404 error, but no more info about what causes it.
– Corni
May 9 '16 at 7:21
Try this rule in your virtual host, RewriteEngine On RewriteRule . "Subdomain does not exist" [404]
– serverliving.com
May 9 '16 at 7:27
That's not solving my problem, I want to have a custom, styled 404 page. Not just a text output.
– Corni
May 9 '16 at 7:31
And it causes an apache error.[404]
is not accepted.
– Corni
May 9 '16 at 7:43
add a comment |
we're running a large project for different customers, each has its own subdomain. Apache should not execute any script if an invalid subdomain is used. Instead, an error page should be shown.
Working:
this is out zzz-default.conf which is the last VHOST and matches all queries that are not catched by another VHOST.
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
Redirect 404 /
DocumentRoot /var/www/html/
ErrorDocument 404 "This Subdomain does not exist."
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What's not working:
ErrorDocument 404 /404.html
This file is located in /var/www/html/
and contains pure html, no scripts.
Our problem seems to be the redirect rule, but we need this to match all subdomains and rewrite to /
.
If I enable this and call an invalid subdomain, I get
Not Found
The requested URL / was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Anybody knows why?
Edit:
The other VHOSTs are defined as
<VirtualHost *:80>
ServerName client.project.example.com
Header always append X-Frame-Options SAMEORIGIN
</VirtualHost>
Include /path/to/local/client/httpd-vufind.conf
There are 13 VHOSTs defined like this and then the above zzz-default.conf
is loaded.
virtualhost errordocument
we're running a large project for different customers, each has its own subdomain. Apache should not execute any script if an invalid subdomain is used. Instead, an error page should be shown.
Working:
this is out zzz-default.conf which is the last VHOST and matches all queries that are not catched by another VHOST.
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
Redirect 404 /
DocumentRoot /var/www/html/
ErrorDocument 404 "This Subdomain does not exist."
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What's not working:
ErrorDocument 404 /404.html
This file is located in /var/www/html/
and contains pure html, no scripts.
Our problem seems to be the redirect rule, but we need this to match all subdomains and rewrite to /
.
If I enable this and call an invalid subdomain, I get
Not Found
The requested URL / was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Anybody knows why?
Edit:
The other VHOSTs are defined as
<VirtualHost *:80>
ServerName client.project.example.com
Header always append X-Frame-Options SAMEORIGIN
</VirtualHost>
Include /path/to/local/client/httpd-vufind.conf
There are 13 VHOSTs defined like this and then the above zzz-default.conf
is loaded.
virtualhost errordocument
virtualhost errordocument
edited May 9 '16 at 10:50
Corni
asked May 9 '16 at 7:01
CorniCorni
1148
1148
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Check error_log for hints, it will show you which file it's trying to locate for /404.html
– serverliving.com
May 9 '16 at 7:15
No. There is no entry since apache restart. There's only oneerror.log
file. It does not get logged. Inaccess.log
, I see the 404 error, but no more info about what causes it.
– Corni
May 9 '16 at 7:21
Try this rule in your virtual host, RewriteEngine On RewriteRule . "Subdomain does not exist" [404]
– serverliving.com
May 9 '16 at 7:27
That's not solving my problem, I want to have a custom, styled 404 page. Not just a text output.
– Corni
May 9 '16 at 7:31
And it causes an apache error.[404]
is not accepted.
– Corni
May 9 '16 at 7:43
add a comment |
Check error_log for hints, it will show you which file it's trying to locate for /404.html
– serverliving.com
May 9 '16 at 7:15
No. There is no entry since apache restart. There's only oneerror.log
file. It does not get logged. Inaccess.log
, I see the 404 error, but no more info about what causes it.
– Corni
May 9 '16 at 7:21
Try this rule in your virtual host, RewriteEngine On RewriteRule . "Subdomain does not exist" [404]
– serverliving.com
May 9 '16 at 7:27
That's not solving my problem, I want to have a custom, styled 404 page. Not just a text output.
– Corni
May 9 '16 at 7:31
And it causes an apache error.[404]
is not accepted.
– Corni
May 9 '16 at 7:43
Check error_log for hints, it will show you which file it's trying to locate for /404.html
– serverliving.com
May 9 '16 at 7:15
Check error_log for hints, it will show you which file it's trying to locate for /404.html
– serverliving.com
May 9 '16 at 7:15
No. There is no entry since apache restart. There's only one
error.log
file. It does not get logged. In access.log
, I see the 404 error, but no more info about what causes it.– Corni
May 9 '16 at 7:21
No. There is no entry since apache restart. There's only one
error.log
file. It does not get logged. In access.log
, I see the 404 error, but no more info about what causes it.– Corni
May 9 '16 at 7:21
Try this rule in your virtual host, RewriteEngine On RewriteRule . "Subdomain does not exist" [404]
– serverliving.com
May 9 '16 at 7:27
Try this rule in your virtual host, RewriteEngine On RewriteRule . "Subdomain does not exist" [404]
– serverliving.com
May 9 '16 at 7:27
That's not solving my problem, I want to have a custom, styled 404 page. Not just a text output.
– Corni
May 9 '16 at 7:31
That's not solving my problem, I want to have a custom, styled 404 page. Not just a text output.
– Corni
May 9 '16 at 7:31
And it causes an apache error.
[404]
is not accepted.– Corni
May 9 '16 at 7:43
And it causes an apache error.
[404]
is not accepted.– Corni
May 9 '16 at 7:43
add a comment |
1 Answer
1
active
oldest
votes
The problem is the redirect rule that matches everything, including your ErrorDocument. The solution is quite simple include the redirect in the 404 response by setting remote URL as the ErrorDocument
:
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
DocumentRoot /var/www/html/
ErrorDocument 404 http://project.example.com/404.html
</VirtualHost>
Hm without theredirect
rule, my PHP application is executed even if this subdomain is not defined. I need this redirect to catch all requests to non-existent subdomains. I've added an example for the other VHOST definitions.
– Corni
May 9 '16 at 10:46
I guess because of my special configuration, it's not possible to have a custom 404 page here.
– Corni
May 23 '16 at 6:41
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f775570%2fapache-2-4-errordocument-for-multiple-subdomains%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is the redirect rule that matches everything, including your ErrorDocument. The solution is quite simple include the redirect in the 404 response by setting remote URL as the ErrorDocument
:
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
DocumentRoot /var/www/html/
ErrorDocument 404 http://project.example.com/404.html
</VirtualHost>
Hm without theredirect
rule, my PHP application is executed even if this subdomain is not defined. I need this redirect to catch all requests to non-existent subdomains. I've added an example for the other VHOST definitions.
– Corni
May 9 '16 at 10:46
I guess because of my special configuration, it's not possible to have a custom 404 page here.
– Corni
May 23 '16 at 6:41
add a comment |
The problem is the redirect rule that matches everything, including your ErrorDocument. The solution is quite simple include the redirect in the 404 response by setting remote URL as the ErrorDocument
:
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
DocumentRoot /var/www/html/
ErrorDocument 404 http://project.example.com/404.html
</VirtualHost>
Hm without theredirect
rule, my PHP application is executed even if this subdomain is not defined. I need this redirect to catch all requests to non-existent subdomains. I've added an example for the other VHOST definitions.
– Corni
May 9 '16 at 10:46
I guess because of my special configuration, it's not possible to have a custom 404 page here.
– Corni
May 23 '16 at 6:41
add a comment |
The problem is the redirect rule that matches everything, including your ErrorDocument. The solution is quite simple include the redirect in the 404 response by setting remote URL as the ErrorDocument
:
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
DocumentRoot /var/www/html/
ErrorDocument 404 http://project.example.com/404.html
</VirtualHost>
The problem is the redirect rule that matches everything, including your ErrorDocument. The solution is quite simple include the redirect in the 404 response by setting remote URL as the ErrorDocument
:
<VirtualHost *:80>
ServerName project.example.com
ServerAlias *.project.example.com
DocumentRoot /var/www/html/
ErrorDocument 404 http://project.example.com/404.html
</VirtualHost>
answered May 9 '16 at 8:42
HBruijnHBruijn
55.5k1090149
55.5k1090149
Hm without theredirect
rule, my PHP application is executed even if this subdomain is not defined. I need this redirect to catch all requests to non-existent subdomains. I've added an example for the other VHOST definitions.
– Corni
May 9 '16 at 10:46
I guess because of my special configuration, it's not possible to have a custom 404 page here.
– Corni
May 23 '16 at 6:41
add a comment |
Hm without theredirect
rule, my PHP application is executed even if this subdomain is not defined. I need this redirect to catch all requests to non-existent subdomains. I've added an example for the other VHOST definitions.
– Corni
May 9 '16 at 10:46
I guess because of my special configuration, it's not possible to have a custom 404 page here.
– Corni
May 23 '16 at 6:41
Hm without the
redirect
rule, my PHP application is executed even if this subdomain is not defined. I need this redirect to catch all requests to non-existent subdomains. I've added an example for the other VHOST definitions.– Corni
May 9 '16 at 10:46
Hm without the
redirect
rule, my PHP application is executed even if this subdomain is not defined. I need this redirect to catch all requests to non-existent subdomains. I've added an example for the other VHOST definitions.– Corni
May 9 '16 at 10:46
I guess because of my special configuration, it's not possible to have a custom 404 page here.
– Corni
May 23 '16 at 6:41
I guess because of my special configuration, it's not possible to have a custom 404 page here.
– Corni
May 23 '16 at 6:41
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f775570%2fapache-2-4-errordocument-for-multiple-subdomains%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Check error_log for hints, it will show you which file it's trying to locate for /404.html
– serverliving.com
May 9 '16 at 7:15
No. There is no entry since apache restart. There's only one
error.log
file. It does not get logged. Inaccess.log
, I see the 404 error, but no more info about what causes it.– Corni
May 9 '16 at 7:21
Try this rule in your virtual host, RewriteEngine On RewriteRule . "Subdomain does not exist" [404]
– serverliving.com
May 9 '16 at 7:27
That's not solving my problem, I want to have a custom, styled 404 page. Not just a text output.
– Corni
May 9 '16 at 7:31
And it causes an apache error.
[404]
is not accepted.– Corni
May 9 '16 at 7:43