Forum Moderators: phranque

Message Too Old, No Replies

Two htaccess 404's on one website?

         

Apparelyzed

1:10 pm on Mar 3, 2008 (gmt 0)

10+ Year Member



This may be possible, maybe not, which is why I'm here!

I currently have a 404 in my htaccess file which points to my homepage. This is in my root folder and works fine.

I have recently shut down a classifieds section on my site, which was a php script in a directory called "disability-equipment". When I look at Google, there are still loads of links pointing to the disability directory, that I want to point to "disability-directory/index.html".

Can I just put an htaccess file in the "disability-equipment" directory pointing all the url's from google which were for the old links to the new index.html file as well as keeping the original htaccess file in my root folder?

Thanks

Simon

Receptional Andy

8:39 pm on Mar 3, 2008 (gmt 0)



Hi Apparelyzed, and welcome to webmasterworld [webmasterworld.com] :)

I'm not convinced I have accurately understood your problem, since the title seems to talk about 404s, whereas your post content about redirection.

A .htaccess file in the root of your website will control all subdirectories too, unless you take steps to prevent this happening.

So, you can redirect your old URLs within the htaccess file in the root directory. No need to create another one

You have a few options for how to perform the redirection, perhaps the simplest of which is mod_alias [google.com]:


Redirect Permanent /old-directory/old-file.html http://www.example.com/new-directory/new-file.html

For more advanced redirection techniques you are best advised to make use of mod_rewrite [google.com]

g1smd

8:42 pm on Mar 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Using your root index page as a 404 page is a bad idea. Set up a custom 404 page with similar content if you need to.

Don't link or redirect to "disability-directory/index.html". Never include the index file filename in a link or redirect.

You can add a new .htaccess file with a new ErrorDocument directive in the respective folder to point to a specific new 404 file in that folder, with the required error message for that particular missing content, however you might just want to set up a set of 301 redirects for any filename in that folder to redirect to the foldername ending in a "/" instead.