vimalmichael
vimalmichael

Reputation: 25

Redirection to custom 404 error page

I was not able to find a straight answer for my question. I have 2 other websites (eg website 'A' and website 'B') under my current website (www.xyz.com). Both the website is in different folder. So to access my sub website url will be www.xyz.com/A/ or www.xyz.com/B/. I have created a 404.html page for my main website (www.xyz.com). How can I use the same 404.html page for my sub websites. I tried ErrorDocument 404 /404.html

It is working for my main website, but not working for my sub websites kindly advice.

Upvotes: 1

Views: 4275

Answers (1)

Synoon
Synoon

Reputation: 2351

Citation from How to redirect your 404

htaccess 404 Error Code Once you have your 404 page setup, all you need to do is send visitors of incorrect url’s to this page. To do this just add the following line to your .htaccess file : ErrorDocument 404 /404.php

Most often, the .htaccess file will be in the home root public_html folder on your server. This can change, for an example if you run you site or blog out of a specific folder within the public_html.

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 errormessages refererring the 404 error to the url of the page. ErrorDocument 404 /errormessages/404.php

That’s all there is to it. Now when a visitor views an incorrect url on your site they will see your custom 404 error message.

when do you have a web.xml with this pattern you can set an errorpage too:

<error-page>
    <error-code>404</error-code>
    <location>/Error404.html</location>
</error-page>

Upvotes: 1

Related Questions