We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

custom error pages | Forum

dave Leader
dave May 8 '13

Thought i would share how to set up your custom error pages. I know there is an article out there on this but honestly took me a bit to find it and it would be sort of confusing for a newbie..

 

So here is how..

 

Create a new folder in the public_html and lets call it for example:  errorpages

 

now add this to the top of your .htaccess

 

ErrorDocument 401 /errorpages/401.html

ErrorDocument 403 /errorpages/403.html
ErrorDocument 404 /errorpages/404.html
ErrorDocument 500 /errorpages/500.html

and also add this line to your .htaccess

 

RewriteCond %{REQUEST_URI} !/errorpages/

now put your 401.html, 404.html, 403.html, 500.html to that errorpages dir.

 

you can prob just leave their  500.phtml file in the root, it came with the install so you can always put it back if you want to.  I took it out and i got a file not found so i guess they do check for it... so just leave it be right where it is, it wont hurt anything..

 

thats it your done...   and you can do this same thing for any special html file you wish to use, just make a special folder for it, and then add the rewrite cond statment in your htaccess ..

 

hope this helps

The Forum post is edited by dave May 8 '13
dave Leader
dave May 8 '13

Update here, actually you do need to leave the 500.phtml in the root because they have the file name hard coded in several of the error management files.  So you can change those files if you want, but i decided not to and just to leave that file there.  I dont want to do changes to the core files and then one day do  an update and then have to remember to mess with those files again. 

 

My personal thought on this, is i hope that the dev team removes this hard code process and lets us handle the error display from our end outside the core, just like many other scripts do.

The Forum post is edited by dave May 8 '13
IB
IB Aug 1 '13
Hi Dave,
Would this help clear my Error Logs?
I'm getting a massive amount of errors.  Mainly 404 errors of missing pages.  Which I don't understand, why they would be missing as the template is from Oxwall.
Every minute there's an error in my logs.  I must have thousands all up.
dave Leader
dave Aug 1 '13

That has nothing to do with your error pages.  What you are seeing is probably bot scripts or manual bots, what they are doing is looking for weaknesses in your script to exploit.

 

It is a long process but basically what they (bots)do is they look for known exploitable files, files that have been reported world wide as having security issues.  This is why you will see requests in your error log (file not found) for files that dont even exist on your server at times because the bots are going thru the worldwide listing they have been assigned.  Many of these files on the list are with large well known scripts like PHPBB, WORDPRESS, and tons of others and mostly open source.

 

That is why when one of these scripts says to update, you update right away because the bots are already being loaded to try the exploit before you update.   Alot of times you will see requests for style files or template files and that is why.  As soon as a template or style file is reported from WORDPRESS to have a issue the bot owners get that data loaded up asap and start them searching.   They also prey on those still on php4 and older versions of files or php or mysql in general because all the security issues are well known by them at this time.

 

Also the bots may purposely look for files not found or try to trigger an error for another reason.  And that is to try to get your server to spit out a mysql error or some other error that will show on the screen which shows  them your login name for Cpanel.  They want to see this

 

bla bla blah (whatever th error message is from apache or php)  is  blah blah  home/public_html/xxxxxx/dir/ and so on. 

 

the xxxxxx is what they want, its your login name for Cpanel.   This is why you never ever ever leave your error display set to on other than for debugging or development, you can leave error loging on but not display errors.  It just gives them an easy way to get a piece of data to store away for later use.

 

But anyway that is why you see all of those, they are bots.   Look at the IP's  if you see multiple IP's looking for files then ban those Ip's  in Cpanel,  that is what i do and over time now my list is clean other than a bunch of "denied by server config"  which is what you want to see.

 

Hope that helps you.

 

  

The Forum post is edited by dave Aug 1 '13
IB
IB Aug 1 '13
Dave, I really appreciate that answer.  I was starting to worry.  But I will check out a few of those IPs first.
I'm guessing that the bot IPs probably wouldn't be from Australia.  At least not the majority.  So I'm going to run a check on those first.  I'd hate to block any members trying to get access.

I was wondering, would all those logs fill up my site cache?  Kairat (one of the plugin devs) helped me clear my cache explaining about the config.php file.
Is that something I need to do on a regular basis?  Reason I'm asking, because I had a 500 Server error a few days ago stopping me from logging in.  He cleared the cache and all was well.
dave Leader
dave Aug 1 '13

Your welcome :)

 

No the cPanel log only holds the last 300 items so your fine and when the bots take a break it does refresh quite often so there are times it will be empty.   There are a number of types of cache but your referring to your template cache which could be and most likey affected by addng a plugin, or changing the css, making a mod to the files.

 

There is also browser cache and also DNS cache.

 

Here are two posts you should take a look at just in case it does help you.

 

http://www.oxwall.org/forum/topic/11506?page=1#post-57943

 

AND

 

http://www.oxwall.org/forum/topic/11064

 

hope that helps.  :)

IB
IB Aug 1 '13
Excellent, thanks.
IB
IB Aug 1 '13
Ok, I checked all of the IPs in the log.
Out of 300, 299 were from my region only (which is to be expected, because the site serves only my city/state/ or at most Australia).
Only 1 was French.

Even my own IP is serving up errors on the log.  But I don't see any.

I'm concerned about that, because does it mean my users are being served errors, or don't they see them like I don't.  Why would that be?   Confused.
Sorry for all the questions.
The Forum post is edited by IB Aug 1 '13
dave Leader
dave Aug 1 '13

Ever heard of proxy's, they might be using proxy's.   How about giving me an example of the error your getting.  Copy from your log to here

 

Remember to change your cPanel username  in the error to xxxxx i do not need to see that and noone does.

IB
IB Aug 1 '13
I'm pretty sure they don't use proxies.  These are all home schooling families.  Parents looking for home school events, groups etc.

See examples:
============================
[Thu Aug 01 22:16:41 2013] [error] [client 124.148.61.253] File does not exist: /home/xxxxxx/public_html/404.shtml

[Thu Aug 01 21:08:38 2013] [error] [client 114.77.243.208] File does not exist: /home/xxxxxx/public_html/favicon.ico

[Thu Aug 01 21:08:38 2013] [error] [client 114.77.243.208] File does not exist: /home/xxxxxx/public_html/403.shtml, referer: http://www.xxxxxxxx.com/join

[Thu Aug 01 19:56:55 2013] [error] [client 114.78.43.103] File does not exist: /home/xxxxxx/public_html/500.shtml, referer: http://www.xxxxxxxx.com/forum/12

[Thu Aug 01 16:24:38 2013] [error] [client 124.186.161.45] File does not exist: /home/xxxxxx/public_html/404.shtml, referer: http://www.xxxxxxxx.com/...se.css?51f652ecea542

[Thu Aug 01 16:06:37 2013] [error] [client 101.118.131.24] (12)Cannot allocate memory: couldn't create child process: /opt/suphp/sbin/suphp for /home/xxxxxx/public_html/index.php, referer: http://www.xxxxxxxx.com/index
============================
This is just a tiny sample.
The Forum post is edited by IB Aug 1 '13
dave Leader
dave Aug 1 '13

Looks like you have some htaccess and php ini rules that are affecting things.  Basically you have told the server to handle html as shtml for your error pages.

 

Couple of ways to handle that, without having you submit your htaccess file and php ini file i think probably the best thing to do is just give the server what it wants for now, you can always read up on how to improve  your htaccess and php.ini files when you have more experience.

 

Just create some very basic html files with a the very basic html tags

html - head -  title - close title - close head - body  - cose body - close html

 

in the body secton put this:

 

Sorry the page does not exist or has been moved, please consult our main domain url to access the site.  If you have been denied server please do not take it personal as it is part of our security feature.  If you are a valid member and have issues please use the contact page on the site to contact us for help.   

 

and name them 404.shtml  403.shtml   500.shtml

 

that should take care of those.

 

and then the favicon just create a file in photoshop or paint and that is 45x45 with your company logo or site initials and name it favicon.ico  and put it in your site root.  You can read about favicions here.   https://en.wikipedia.org/wiki/Favicon 

 

and then open your php.ini file (do not open it in a word processer, never edit files using word processor it leaves hidden codes and will mess up your day)  use notepad or programmers notepad (free download google it)

 

add this line to the top area someplace make sure you dont already have that command in there if so just change the number, that should fix your memory issue.

memory_limit = 300M

 

 

The Forum post is edited by dave Aug 1 '13