MyBB Community Forums

Full Version: .htaccess 404 ErrorDocument and 301 redirect
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using MyBB and Apache. Here is my .htaccess code:

<IfModule mod_rewrite.c>
    ErrorDocument 403 /index.php
    ErrorDocument 404 /index.php
</IfModule>

If I visit a non-exist url www.example.com/xxxxx/ it did display the homepage index.php However, it did a 302 redirect, which means the url www.example.com/xxxxx/ remains the same in the bar.

I want a 301 redirect! How can I do this?

Thanks a lot!
It shouldn't do any redirects actually but instead just serve the page with the appropriate error code (more or less the same way rewrites work).

If you want it to redirect, you have to use ErrorDocument 404 http://fullurl/to/target

However if you do this, naturally the clients will see the redirect, and not the 404 error code. So it changes things, like how search engines handle errors on your page. Also if the full url you gave also ends up being 404, you have a redirect loop on your hands.