Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-13-2011, 11:37 PM #1
- Join Date
- Jun 2008
- Thanked 0 Times in 0 Posts
Redirect Any 404 Errors Within Folder
How would I go about redirecting 404 errors within specific folders using htaccess?
For example, let's say I have the folder structure like this:
site.com/goat/ <= this page exists
site.com/goat/page/ <= this page exists
site.com/goat/404/ <= this page does NOT exists
If someone were to navigate to site.com/goat/404/ (or any page for that matter that doesn't exist within the /goat/ main directory), how would I go about redirecting them to the main /goat/ directory?
So if you visit an actual page that exists within /goat/ you see the page as normal. However, if you visit a url within /goat/ that returns a 404, you get redirected back to the main /goat/ root.
09-15-2011, 09:22 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
Use an error document instruction:
I don't believe there is an easy way to determine where you go beyond this. You could probably specify a base directory and use multiple .htaccess files if you wanted to do something different for each sub-directory.Code:ErrorDocument 404 /goat/