would you know what the issue is?
This works:
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
ErrorDocument 404 /index.html
ErrorDocument 403 http://www.dsfds.lu
This doesn't work and return a "500 Internal server error":
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
ErrorDocument 404 /index.html
ErrorDocument 403 http://www.dsfds.lu
Redirect 301 /biographie-dfd-fdd/ biographie.html
You need to use the full URL as the second argument
Redirect 301 /biographie-dfd-fdd/ http://website.com/biographie.html
Related
I'm trying to implement a 404 error page. I have this project structure:
+Project
+---index.html
+---404.html
+---.htaccess
My .htaccess contains this line: ErrorDocument 404 /404.html
but this URL doesn't show my 404.html page:
http://localhost:63342/Project/wrong.html
Instead, I get the default Opera 404 page: https://ibb.co/XsFq5nZ
Whereas, my 404.html page looks like this: https://ibb.co/ZX7XB1d
The response from wrong.html is this: https://ibb.co/mJ2KztK
What is the problem?
ErrorDocument 404 /404.html
http://localhost:63342/Project/wrong.html
It would seem you have not specified a root-relative URL-path. From your URL structure, it should be:
ErrorDocument 404 /Project/404.html
UPDATE:
Try resetting to the default Apache error document:
ErrorDocument 404 default
Test that and then add your custom error document:
ErrorDocument 404 default
ErrorDocument 404 /Project/404.html
Make sure your 404.html file contains enough content. Some browsers will default an error response if the response received from the server is too small.
I've blocked all IP's except my own from an old website, I've added a custom HTML page to replace the default 403, but it's not displaying?
order deny,allow
deny from all
allow from (ip)
allow from (ip)
ErrorDocument 403 http://www.mywebsite.co.uk/error.html
I can access the html page in my browser by visiting www.mywebsite.co.uk/error.html but from a blocked IP it still displays the standard 403 error message
Any ideas?
Thanks
in CakePHP v3.2.12
I get GET http://test/debug_kit/js/toolbar.js 404 (Not Found)
When I try this:
cd webroot
ln -s ../vendor/cakephp/debug_kit/webroot debug_kit
I get this:
toolbar.js:53 GET http://test/debug_kit/toolbar/b977c7b2-a414-4970-8ac3-ef48e3e8982e 404 (Not Found)
I found out I was missing AllowOverride All from my .conf file stated in the CakePHP documentation
I tried all I found at apache documentation and other sugestions found at stackoverflow and blogs.
When I add the folloowing line to any configuration file like /etc/apache2/apache2.conf or /etc/apache2/conf.d/localized-error-pages or /etc/apache2/httpd.conf or /etc/apache2/sites-enabled/000-default:
ErrorDocument 503 "This is an error msg" or even an html message
ErrorDocument 503 "<h1> This is an error message </h1>
or an external url redirect ErrorDocument 503 http://www.google.com it works.
But when I try an internal redirect like ErrorDocument 503 /ERROR_503.html
or ErrorDocument 503 /error/ERROR_503.html I get the default message with last line:
Additionally, a 503 Service Temporarily Unavailable
error was encountered while trying to use an ErrorDocument to handle the request.
I tried to put the html error page at the DocumentRoot var/www, at var/www/error.
Try to uncomment all the file /etc/apache2/conf.d/localized-error-pages that sets all errors to custom pages with internationalization that are at /usr/share/apache2/error.
And as the messages inside this files are the same as the default, the line
Additionally, a 503 Service Temporarily Unavailable
error was encountered while trying to use an ErrorDocument to handle the request.
is not shown anymore. But if I change the line
`ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var`
at the localized-error-pages file to a new html placed at the same page, the error is back
and the page is not shown. If I edit the file HTTP_SERVICE_UNAVAILABLE.html.var nothing change at the browser message too.
Some more information: I'm using apache2 just to redirect all request on port 80 to tomcat at port 8089 via an worker. My configuration files are https://dl.dropboxusercontent.com/u/1105054/apache.zip
This took me way tooo long (partially due to spelling), but I thought I'd post my whole virtual host file since it might be useful.
You'll want to make sure you've specified a DocumentRoot, and that you do the ProxyPass /file.html ! before your main ProxyPass /.
<VirtualHost *:443>
DocumentRoot /var/www/html
#ProxyPreserveHost On
<IfModule env_module>
# Fake SSL if Loadbalancer does SSL-Offload
SetEnvIf Front-End-Https "^on$" HTTPS=on
</IfModule>
SSLEngine on
SSLCertificateFile file
SSLCertificateKeyFile file
SSLCertificateChainFile file
ProxyPass /maintenance-message.html !
ProxyPass /maintance-message_files !
ProxyPass / "ajp://localhost:8009/"
ProxyPassReverse / "ajp://localhost:8009/"
ServerName server.something.com:443
ErrorDocument 503 /maintenance-message.html
</VirtualHost>
In my case I just added this ProxyPass line to my virtualserver config:
ProxyPass /serverError.html !
ErrorDocument 503 /serverError.html
That tells the proxy to go to the DocumentRoot and search for the error page.
Also you may find useful this answer: https://stackoverflow.com/a/13019667
I faced the same issue too and after deep searching I found here the best (and only?) solution from #Loren.
Worked after setting ProxyPass /file.html ! before the main ProxyPass / and NOT after.
Also, DocumentRoot is needed as well.
When looking at the documentation for nginx's error_page directive, it seems that one has to manually list out every possible status code that nginx (or an upstream server) could return.
For example:
error_page 404 /404.html;
error_page 502 503 504 /50x.html;
error_page 403 http://example.com/forbidden.html;
error_page 404 = #fetch;
Is there anyway of producing a wildcard for ALL status codes that are not specified directly... For example:
error_page 404 /404.html;
error_page 5xx /50x.html;
or
error_page 404 /404.html;
error_page 502 503 504 /50x.html;
error_page #catchall /5xx.html;
It is not possible.
Moreover, it is not recommended to blindly list all codes, as
nginx allows to redefine all response codes, including ones you don't really want to redefine except in a few very specific situations (e.g. you don't normally want to redefine 304 (Not Modified), and probably not 302 (Found) unless there are very specific reasons);
redefining some of the error codes might cause more harm than good (e.g. redefining 400 (Bad Request) is a bad idea).
location {
...
error_page
301 302 303 304 307 308
400 401 402 403 404 405 406 408 409 410 411 412 413 414 415 416 421 429
500 501 502 503 504 505 507
#errors;
location #errors {
internal;
default_type "text/plain; charset=utf-8";
return 200 "$status\n";
}
}
Responses can provide status messages like "404 Not Found" by defining a map for each HTTP code, as described in One location block for all Nginx error codes