Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Redirecting URL requests in Apache2

Add the below line 

redirect /test     http://www.mysite.com

to

/etc/apache2/sites-available/default file – if it is applicable for the entire site

(or)

.htaccess file - if it is applicable to the particular application

(In the above case AllowOverride All or AllowOverride redirect should be present in /etc/apache2/sites-available/default file)



Customizing error messages in apache2

Add this line
 errorDocument 404 /error_pages/404.html
to
 /etc/apache2/sites-available/default file – if it is applicable for the entire site
 (or)
 .htaccess file - if it is applicable to the particular application
(In the above case AllowOverride All or AllowOverride redirect should be present in /etc/apache2/sites-available/default file)

In this case, 404 error is getting redirected to 404.html file in error_pages directory.
Now create a file called 404.html file in error_pages directory in /var/www
404.html should contain the following:
<html><body><h1>It works!</h1>
<p>The requested site is under maintainence.</p>
</body></html>