LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache redirect for non existing page (https://www.linuxquestions.org/questions/linux-server-73/apache-redirect-for-non-existing-page-680818/)

cooljai 11-03-2008 08:05 AM

Apache redirect for non existing page
 
dear members,

I want a rewrite rule to achieve something like this:

At present, when user writes http://www.example.com/tags/car.html the car.html page open and if the car.html is not there, our site's 404 error page is displayed to indicate that car.html is not there.

I want to redirect to /tags when a page below it not exist instead of displaying 404 page.

So,

http://www.example.com/tags/car.html if not found, open http://www.example.com/tags


Thanks

bathory 11-03-2008 09:00 AM

You can use the ErrorDocument directive to do what you want. If your index page is, for example, index.htm and the path to the directory you want to control is /path/to/docroot/tags
Code:

<Directory /path/to/docroot/tags>
...
ErrorDocument 404 /tags/index.htm
</Directory>



All times are GMT -5. The time now is 11:38 AM.