Most of us have come across this error: “Fatal error: Allowed memory size of xxxxxx bytes exhausted (tried to allocate yyy bytes) in ….” in the php error logs.
In php, running out of memory in usually a sign that your php script is not too well written or has a bug or two in it; However sometimes even the best of our php scripts still require more memory than usual especially if it is handling large amounts of data.
Luckily in php, increasing the memory limit is an easy task to do and can be done in a number of ways.
Apache allows you to customize the server at the directory level, using .htaccess files. Below how to use them to serve custom 404 error (page not found), and other common error pages, to your users.
Alternately, You can place the 404 error template anywhere you want in a folder. For example you could place all error messages in a folder called “errormsg” refererring the 404 error to the url of the page.[php toolbar=”false” classname=”one_line”] ErrorDocument 404 /errormsg/404.php [/php]
It occurred to me that just maybe you don’t want to display your site with the www subdomain prefix. In that case you could deploy the following code in your .htaccess file to redirect www to non-www. By doing so, users will access your site at http://domain.com not http://www.domain.com.
If your website is hosted on an apache server, a redirect from www to non-www is a simple implementation. Add the following to your .htaccess file[php toolbar=”true” classname=”one_line”] RewriteEngine On
Add the above code to you .htaccess file and replace domain.com with your domain name.