#1
  1. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Aug 2010
    Posts
    19
    Rep Power
    0

    .htaccess Changing Folder On Your Site .... ?


    Hi Everyone,

    I changed a folder name on my site and I would like to know how would I write code in a .htaccess file to allow for such a change meaning Google, Yahoo and Bing will be able to index my site faster because of the .htaccess file. For example, my old folder was "old-folder" my new folder is "new-folder" what code is needed to write in a .htaccess file to let the major search engines know I've made such a change. Thanks everyone for your help!

    RewriteEngine on
    RewriteBase /
    RewriteRule .....
  2. #2
  3. SEO Consultant
    SEO Chat High Scholar (3500 - 3999 posts)

    Join Date
    Apr 2010
    Location
    Atlanta, GA
    Posts
    3,616
    Rep Power
    1952
    Originally Posted by jamessorenson
    Hi Everyone,

    I changed a folder name on my site and I would like to know how would I write code in a .htaccess file to allow for such a change meaning Google, Yahoo and Bing will be able to index my site faster because of the .htaccess file. For example, my old folder was "old-folder" my new folder is "new-folder" what code is needed to write in a .htaccess file to let the major search engines know I've made such a change. Thanks everyone for your help!

    RewriteEngine on
    RewriteBase /
    RewriteRule .....
    You're talking about a 301 redirect, code would be as follows:

    redirect 301 "/old_folder" http://www.domain.com/new_folder

    More about htaccess and 301's here: http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm

    Comments on this post

    • EGOL agrees
    www.V2INTERACTIVE.net - SEO Web Design | On-Page SEO | SEO Audits & Reports | Link Building
    BASED IN ATLANTA, GA. Contact: Skype/Phone/Email (Discounted rates available for SEOChat members only - email seochat@v2interactive.net)
    Please EMAIL me at the above address and do not send Private Messages. I rarely check them and your message will be lost.
  4. #3
  5. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Aug 2010
    Posts
    19
    Rep Power
    0
    Hi Joshz,

    Thanks for the reponse and link. Would the 301 redirect code look like this .....

    RewriteEngine on
    RewriteBase /
    RewriteRule "/old_folder" http://www.domain.com/new_folder

    Thanks again.


    Originally Posted by joshz
    You're talking about a 301 redirect, code would be as follows:

    redirect 301 "/old_folder" http://www.domain.com/new_folder

    More about htaccess and 301's here: http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm
  6. #4
  7. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jun 2008
    Posts
    464
    Rep Power
    92
    Well, the cleanest way to write it would be:

    Code:
    Options +FollowSymLinks
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^\/old_folder\/(.*)$ http://www.domain.com/new_folder/$1 [L,R=301]
    </IfModule>
    This version will work on condition that all your pages have the same name in the old folder and in the new one.

    Example old_folder/about.html will redirect to new_folder/about.html.

    Otherwise, you can use

    "redirect 301" or "redirect permanent" on a page per page basis.

    Comments on this post

    • joshz agrees : however some servers will not respond to this, i know from hostgator did not when i used it
    • fathom agrees
    • EGOL agrees
    Last edited by Keiros; Dec 3rd, 2010 at 11:48 AM.
    SEO for the dummies
    “Outside of a dog, a book is a man's best friend. Inside of a dog it's too dark to read.” — Groucho Marx.
  8. #5
  9. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Aug 2010
    Posts
    19
    Rep Power
    0
    Hi Keiros,

    Thanks for the reply.

    This version will work on condition that all your pages have the same name in the old folder and in the new one.
    I have a different ending for each page. Meaning all of my pages aren't the same. Although in my "old-folder" each page ending was called the same name but all I did differently was change the .php extension (which I have a .htaccess code) and also changed the folder from "old-folder" to "new-folder"

    For example

    mysite.com/new-folder/page1.php <<---- each page is different but in the "old-folder" this page was also called mysite.com/new-folder/page1.php. So does that make it different?

    mysite.com/new-folder/page2.php
    mysite.com/new-folder/page3.php
    mysite.com/new-folder/page4.php

    Will the above code work for my 301 redirect? or will I need to tweak the 301 redirect? on a page by page basis?

    Thanks




    Originally Posted by Keiros
    Well, the cleanest way to write it would be:

    Code:
    Options +FollowSymLinks
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^\/old_folder\/(.*)$ http://www.domain.com/new_folder/$1 [L,R=301]
    </IfModule>
    This version will work on condition that all your pages have the same name in the old folder and in the new one.

    Example old_folder/about.html will redirect to new_folder/about.html.

    Otherwise, you can use

    "redirect 301" or "redirect permanent" on a page per page basis.
  10. #6
  11. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jun 2008
    Posts
    464
    Rep Power
    92
    Sorry, I did not come back earlier, as I've been pretty busy these last weeks. The more you explain...the less I understand LOL.

    mysite.com/new-folder/page1.php <<---- each page is different but in the "old-folder" this page was also called mysite.com/new-folder/page1.php.
    Where does the difference stand?

    Have you visited the link provided by Joshz and done some home work by yourself?

    When the rewrite rules becomes too complex to be easily handled by htaccess, I generally use a php script,

    example:

    in .htaccess, this simple directive:

    RewriteRule ^old_folder\/$ /redirector.php [L]

    in redirector.php

    Code:
    <?php
    if($_SERVER['REQUEST_URI'] = "/old_folder/page1.php") 
    { 
    header("HTTP/1.1 301 Moved Permanently"); 
    header("Location: http://".$_SERVER['HTTP_HOST']."/new_folder/pagez.html"); 
     exit; 
    >?
    adding as many "if" as necessary if I cannot establish a strict rule. That's actually dealing with each page individually, but it keeps the htaccess cleaner (all the mess in one place). In term of perfomances, I'm not sure that it is better, but I feel more confortable with php and avoid surprizes with the way your host is handling htaccess directives.

    Comments on this post

    • KernelPanic agrees : Dude, where you been. Don't be a stranger this place needs you.
    • joshz agrees : i want to make your babies too, KP can piss off
  12. #7
  13. Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Jun 2008
    Posts
    464
    Rep Power
    92
    KernelPanic agrees: Dude, where you been. Don't be a stranger this place needs you.
    joshz agrees: i want to make your babies too, KP can piss off
    Sorry, I did not see your comment earlier, but if you could help me with PowerVM, VIOS, NPIV and Websphere Application Server, I would come back more often. Meanwhile, I've too many new concepts to learn and not enough time.

Similar Threads

  1. See your sandboxed site's rank if it weren't sandboxed
    By dazzlindonna in forum Google Optimization
    Replies: 306
    Last Post: Feb 5th, 2006, 10:01 AM
  2. preStart the sandbox !!
    By Canuck in forum Google Optimization
    Replies: 21
    Last Post: Oct 6th, 2005, 04:42 AM
  3. New site. changing link to home page in nav bar
    By motski in forum Google Optimization
    Replies: 2
    Last Post: Jul 10th, 2005, 08:32 PM
  4. Changing domain name on site blocked by Google
    By mark754 in forum Google Optimization
    Replies: 11
    Last Post: Sep 3rd, 2004, 12:08 AM

IMN logo majestic logo threadwatch logo seochat tools logo