Results 1 to 15 of 15
  1. #1
    Troll Killer and best Snooper!
    I decide when the pigs fly!
    Rhea's Avatar
    Join Date
    January 18th, 2005
    Location
    New York, USA
    Posts
    6,195
    How do I redirect an entire directory?
    Hey kids! I am deleting an entire directory on one of my sites. Rather than have each page redirect somewhere else on my site, is there anything I can do that will cause anyone who tries to access any URL in that directory to be redirected to my home page?

    TIA!

  2. #2
    ABW Ambassador MoneyBusiness's Avatar
    Join Date
    March 14th, 2006
    Posts
    2,051
    You could do a redirect in your .htaccess file (if you have access to it). You would enter something like:

    Redirect /yourdirectory http://www.yoursite.com/yournewdirectory
    Follow my dog, Maya, and I, as we fumble around the affiliate marketing world: www.MarketingMaya.com
    Recent Project: Cheap Personal Checks (using DigitalQuill)

  3. #3
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    Actually, it's a little more complicated than that. Rhea wants everything going to the home page, not to the same file in a different directory.

    I think you would want something like:

    Redirect /yourdirectory.*$ http://www.yoursite.com/index.html

    If you don't include the ".*$" part, the rest of the original URL will be appended to the destination URL.
    Michael Coley
    Amazing-Bargains.com
     Affiliate Tips | Merchant Best Practices | Affiliate Friendly? | Couponing | CPA Networks? | ABW Tips | Activating Affiliates
    "Education is the most powerful weapon which you can use to change the world." Nelson Mandela

  4. #4
    Member ABCMonkey's Avatar
    Join Date
    July 20th, 2006
    Posts
    83
    Rhea, lets us know how and which suggestion works for you. I'm sure this will help others, your experience.

  5. #5
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    Los Angeles
    Posts
    4,053
    The default for Redirect is Temporary - a 302 redirect, and you don't really want that (some search engines still can't handle it). 301 or Permanent is the best option, but you have to specify it.

    Redirect 301 /yourdirectory.*$ http://www.yoursite.com/index.html

    Good to know about that wildcard for not appending the filenames, I got totally messed up when trying to redirect a bunch of individual pages to a different directory with different page naming. It would have been far better to just redirect all the old ones to the index page on a new directory and start new interior pages from scratch. It'll come in handy when deleting a whole section on a site.

  6. #6
    Troll Killer and best Snooper!
    I decide when the pigs fly!
    Rhea's Avatar
    Join Date
    January 18th, 2005
    Location
    New York, USA
    Posts
    6,195
    Ummmm...guys? You're all very nice to help me out but I still don't know what I'm supposed to do. Can you give it to me in baby steps puleeze? Starting with, "Open your htacess page in Notepad..."

    I shit you not, I'm that clueless!

  7. #7
    ABW Ambassador MoneyBusiness's Avatar
    Join Date
    March 14th, 2006
    Posts
    2,051
    Do you have access to your .htaccess file? You may find it at the root directory of your site.

    I usually just download mine via ftp (to my local drive), make a change, and upload it.

    If you do have access to it, simply open in something like notepad or wordpad.

    Then, on a blank line, enter the line of code that Michael provided (not mine - I was intoxicated by a big plate of lasagna when I wrote that..)

    Save your file (make sure you don't add an extension when you save it. It should stay as ".htaccess"), then upload it back to the same location.

    That's about all I can say. It's pretty straightfoward, and I'm not sure how you have your server set up.

    Good luck!

    edit: if you're unsure about changing your .htaccess file, just make a backup of it. if something goes wrong, throw it back up there, and you'll be back to where you started.
    Follow my dog, Maya, and I, as we fumble around the affiliate marketing world: www.MarketingMaya.com
    Recent Project: Cheap Personal Checks (using DigitalQuill)

  8. #8
    Troll Killer and best Snooper!
    I decide when the pigs fly!
    Rhea's Avatar
    Join Date
    January 18th, 2005
    Location
    New York, USA
    Posts
    6,195
    Okay, well I'm not so lost that I don't know how to use FTP but after that part I guess I got lost because it did not work.

    This is what I put in my .htaccess file which I uploaded to the root for the domain.

    Redirect /mydirectory.*$ http://mydomain.com/index.html

    When that didn't work I tried:

    Redirect 391 /mydirectory.*$ http://mydomain.com/index.html

    That didn't work either.

    So, what did I mess up? :sobbing:

  9. #9
    ABW Ambassador best123's Avatar
    Join Date
    July 5th, 2006
    Posts
    571
    Quote Originally Posted by Rhea
    Okay, well I'm not so lost that I don't know how to use FTP but after that part I guess I got lost because it did not work.

    This is what I put in my .htaccess file which I uploaded to the root for the domain.

    Redirect /mydirectory.*$ http://mydomain.com/index.html

    When that didn't work I tried:

    Redirect 391 /mydirectory.*$ http://mydomain.com/index.html

    That didn't work either.

    So, what did I mess up? :sobbing:
    I think .htaccess only works on an Apache Web Server

    Is your website hosted on an Apache Web Server?

    http://httpd.apache.org/docs/1.3/howto/htaccess.html

  10. #10
    Troll Killer and best Snooper!
    I decide when the pigs fly!
    Rhea's Avatar
    Join Date
    January 18th, 2005
    Location
    New York, USA
    Posts
    6,195
    Yep, it must be an Apache server. I've had a .htacess file handling my error page redirects for years.

    Maybe I messed up where the spaces go in the string?

  11. #11
    http and a telephoto
    Join Date
    January 18th, 2005
    Location
    NYC
    Posts
    17,708
    301 not 391...
    Deborah Carney
    TeamLoxly.com BookGoodies.com ABCsPlus.com

  12. #12
    Troll Killer and best Snooper!
    I decide when the pigs fly!
    Rhea's Avatar
    Join Date
    January 18th, 2005
    Location
    New York, USA
    Posts
    6,195
    Thanks Deb. I put 301 in the htaccess file, just didn't type it right in my post here.

  13. #13
    ABW Ambassador MoneyBusiness's Avatar
    Join Date
    March 14th, 2006
    Posts
    2,051
    I'm going to take the dangerous chance here (everyone's welcome to correct me)

    Just for kicks, I went ahead and tried my earlier suggestion:

    Redirect /myOldDirectory http://www.mydomain.com/myNewDirectory

    When I then tried a URL, such as: http://www.mydomain.com/myOldDirectory/SomeOldFile.html, it was redirected to:

    http://www.mydomain.com/myNewDirectory/SomeOldFile.html

    What it seems to do, is redirect the core part of the URL (domain,directory). This assumes the file names are the same in each directory.

    I assume (surprise), if you also put the 301, it should be suitable for the SE's?

    Ok, I know some of you guys out there know more about this than I do...So I'm ready for my brow beating..
    Follow my dog, Maya, and I, as we fumble around the affiliate marketing world: www.MarketingMaya.com
    Recent Project: Cheap Personal Checks (using DigitalQuill)

  14. #14
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    Los Angeles
    Posts
    4,053
    If you don't specifically say 301 or Permanent it'll be a 302 - Temporary (by default), and you don't want temporary. It needs to be a permanent redirect.

    Check the old URL that's being redirected here and see what it comes back with

    http://www.rexswain.com/httpview.html

  15. #15
    http and a telephoto
    Join Date
    January 18th, 2005
    Location
    NYC
    Posts
    17,708
    ugh, I actually *do* this and forgot that I do it. Rhea, it's actually very easy. You make a special htaccess file and load it just in that directory. Leave the directory there but delete all the files... The htaccess will be one line:

    redirect 301 /directoryname /homepagename

    That's it... that's all there is to it....
    Deborah Carney
    TeamLoxly.com BookGoodies.com ABCsPlus.com

  16. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: May 21st, 2009, 05:14 AM
  2. How do I redirect an entire directory?
    By Rhea in forum Midnight Cafe'
    Replies: 13
    Last Post: August 5th, 2006, 10:24 AM
  3. getting an entire feed
    By QponCentral in forum ShareASale - SAS
    Replies: 7
    Last Post: February 22nd, 2004, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •