[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Re-Directing users on a 404 error



Carrie,

>For just one site, drop an .htaccess file into the 'web' directory of
>the site, with these contents:
>ErrorDocument 404 /error.html

I tried that one and it did not work...  But a very nice guy "Bill" posted a message here a while back and though a bit more complicated... worked like a charm!! I guess I will repost the directions because they are so classicly easy to follow and are probably not in the archives yet..

Note: the file may not be in the exact location noted... on all machines (slightly different on my R3)

WS

**********
This is an alternate way to handle 404 error pages for a specific domain

The following requires telnet or SSH access to your machine and editing the
httpd.conf file.

Back up the conf file  FIRST!
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backup

Now, view the original conf file using vi
vi /etc/httpd/conf/httpd.conf

GO DIRECTLY TO THE <VIRTUAL HOST> FIELD FOR THE DOMAIN

/nameofdomain.com

You will see a file like the one below.  Notice the line that begins with
ErrorDocument.
That is the line you need to add for your 404 error document.  You can also
add other
error codes if you wish on a separate line

-------- EXAMPLE FILE  --------
NameVirtualHost 77.65.45.206
<VirtualHost 77.65.45.206>
ServerName www.somedomain.com
ServerAdmin admin
DocumentRoot /home/sites/site2/web
RewriteEngine on
RewriteCond %{HTTP_HOST}                !^77.65.45.206(:80)?$
RewriteCond %{HTTP_HOST}                !^www.somedomain.com(:80)?$
RewriteRule ^/(.*)                      http://www.somedomain.com/$1 [L,R]
RewriteOptions inherit
ScriptAlias /cgi-bin/ /etc/httpd/ssl/www.somedomain.com/
AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site2/users/$1/web/$3
ErrorDocument 404 http://somedomain.com/404.html
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
# AddHandler chiliasp .asp
# AddHandler chiliasp .asa
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
AddHandler server-parsed .html .htm .shtml
AddType    text/html     .shtml
</VirtualHost>
------ END EXAMPLE FILE --------

Just below the AliasMatch, start an empty line and add the following;

ErrorDocument 404 http://domainname.com/404.html

You will need to get this error document name from the customer.

Now, save changes
<esc>:wq

Now, reload the web server;
/etc/rc.d/init.d/httpd reload

***********