ErrorDocument 403 custom page not displays - html

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

Related

.htaccess ErrorDocument 404 doesn't work on localhost

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.

Dnsmasq failing to catch 307 redirect for https?

I am currently doing some debugging on my website which involves calling the facebook API. I've installed dnsmasq to work with my mac os X to redirect all request to facebook.com to 127.0.0.1
This is my entry in dnsmasq.conf:
address=/facebook.com/127.0.0.1
I also have /etc/resolver/com with nameserver 127.0.0.1
When I turn dnsmasq on, visiting facebook.com will result in a PAGE NOT FOUND error in chrome. This shows that my dnsmasq is working.
However, I noticed that chrome will redirect http://www.facebook.com to https://www.facebook.com due to HSTS. I went on to chrome://net-internals#hsts to delete facebook.com's entry.
The strange thing is, when I am debugging, I see that facebook.com is indeed returning 307 redirects for http://www.facebook.com (See image)
This is very strange because the domain facebook.com is currently resolved to be 127.0.0.1 on my computer! Furthermore, when I dig more into the request, I do see that the request is valid:
Where is this 307 redirect coming from if facebook.com is unresolvable?
307 is an internal browser based redirect for HTTP Strict Transport Security (HSTS). It does not come from the server - it's a fake response created by the browser.

Redirect denied IP addresses using htaccess

I have denied some IP addresses using .htaccess.
How to redirect to a page (banned.something.com) when they try to open my website?
Code:
deny from 176.xx.xxx.xx
You can redirect the banned ip to a specific page or url using the following in htaccess :
ErrorDocument 403 http://banned.example.com
DenyFrom 176.xx.xxx.xx

How to solve add a custom error 503 page html on ubuntu apache2 using it with mod_jk and virtual host redirecting to tomcat

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.

404 error page redirection

I've setup a custom 404 error page using the following code.
ErrorDocument 400 /errors.php
But when I check the headers sent i see that first a 301 moved permanently is sent followed by a 404 error header. So is it good for seo will it create problem with bots.
My second question is reg. transfer of non-existent sub-domains to 404 error pages.I'm using Cpanel and i want only the subdomains created in CPanel to work and i've created a wildcard redirect but non existent subdomain gives me a OK status.How do i redirect it to 404 page.
Thanks.
googlebot-news has special requirements published recently, like they won't acept old site schema-s any more