1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

301 Redirect Demo website links to Live Site. Webmaster Errors...HELP!

Discussion in 'Blogging' started by ran60616, Feb 23, 2015.

  1. ran60616

    ran60616 Regular Member

    Joined:
    Jan 17, 2013
    Messages:
    219
    Likes Received:
    296
    Location:
    A place like no other!
    Hi All,

    Need some help from people who might know this subject.

    I created a DEMO site to test a new theme on my live domain/site like this > www.mysite.com/demo/ (all the pages in my live site).

    Now I have successfully switched the new theme to the live site, and hence lost all the links that goes by www.mysite.com/demo/...

    Unfortunately Google indexed all the pages that my demo site had > www.mysite.com/demo/ (more than 1000 pages). Therefore now it's throwing 404 page errors on Google Webmaster Tools.

    Will adding a 301 redirect from www.mysite.com/demo to www.mysite.com via .htaccess file solve this issue? If so, what is the correct code I need to add?

    Any help would be much appreciated.

    Thanks!
     
  2. Gogol

    Gogol Jr. VIP Jr. VIP

    Joined:
    Sep 10, 2010
    Messages:
    3,478
    Likes Received:
    3,108
    Gender:
    Male
    Under www.mysite.com/demo
    add a .htaccess with the following:

    Code:
    RewriteRule ^demo/(.*)$ /$1 [R=301,NC,L]
    
    Now go to the urls and check if everything redirects properly. Once done, go to your webmasters account. GO to the 404 error list. Select all and mark as fixed.
     
    • Thanks Thanks x 2
    Last edited: Feb 23, 2015
  3. ran60616

    ran60616 Regular Member

    Joined:
    Jan 17, 2013
    Messages:
    219
    Likes Received:
    296
    Location:
    A place like no other!
    THANK YOU so much for the help.

    One question, I have a .htaccess file for the www.mysite.com only, since as mentioned I created the Demo site on my live website with a separate WP install. Since deleting all that and moving the new theme to the live site, I have no access to any demo files.

    Only have direct access to the www.mysite.com .htaccess file via YOAST SEO plugin :)

    Thanks again!
     
  4. Gogol

    Gogol Jr. VIP Jr. VIP

    Joined:
    Sep 10, 2010
    Messages:
    3,478
    Likes Received:
    3,108
    Gender:
    Male
    Well, you would need FTP.A shell script can do the trick but I can't discuss that over here, as hacking discussions are not permitted in BHW.

    You will need to move all the files to the root. your sub-folder will only have the .htaccess file with the above-mentioned rule.