SEO and 301 Redirect code

by ND
12 replies
Hi Guys,
I'm taking an old website I have and 301 redirecting it to a brand new site.

The problem is that it has about 20 pages ending in www.oldsite/public_html/oldpage.html
and I want them all to go to my new website which doesnt have html extensions.
www.NEWsite/NEWPAGE


what is the code for redirecting .html to regular webpage?

I tried this...

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.NEW WEBSITE.com/$1 [R=301,L]

But it only works for the homepage!
thanks
#301 #code #redirect #seo
  • Profile picture of the author tweakr
    You will probably have to define each one individually if the file names have changed, something like this.

    Code:
    redirect 301 /current/currentfile.html http://www.newdomain.com/new/newfile
    {{ DiscussionBoard.errors[5441182].message }}
    • Profile picture of the author frenchsquared
      Originally Posted by tweakr View Post

      You will probably have to define each one individually if the file names have changed, something like this.

      Code:
      redirect 301 /current/currentfile.html http://www.newdomain.com/new/newfile

      Yep... this would probably be easiest. You said you only have about 20 pages. Im certain there is a dynamic way to do it, but it would be faster just to make the 20 individual ones.
      {{ DiscussionBoard.errors[5441654].message }}
    • Profile picture of the author ND
      Originally Posted by tweakr View Post

      You will probably have to define each one individually if the file names have changed, something like this.

      Code:
      redirect 301 /current/currentfile.html http: // www.newdomain.com/new/newfile
      ok I tried this...
      de
      Options +FollowSymLinks
      RewriteEngine on
      RewriteRule (.*) http://www. newsite/$1 [R=301,L]
      redirect 301 /current/currentfile.html http: // www.newdomain.com/new/newfile

      the home page works but the second one goes to
      www .NEW WEBSITE/public_html/oldpagename.html/
      resulting in a 404 page

      (My new wordpress website then says "Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post." with a search box.)

      The old website pages were in the public html folder.
      Like www .OLD WEBSITE/public_html/oldpagename.html

      I want to send it to to new wordpress site at:
      www .NEW WEBSITE/newpagename

      Is that the problem?
      how can I fix that?
      thanks!
      Signature
      NOVA CUSTOM PRINTING- Graphic Design, Custom Printed Labels, Stickers, T Shirts & CD/DVD Manufacturing:
      NOVA CUSTOM LABEL PRINTING, NOVA CUSTOM T SHIRT PRINTING, NOVA DISC
      {{ DiscussionBoard.errors[5453184].message }}
  • Profile picture of the author Tkato
    If it's only 20 pages why don't you manually redirect them? the faster you do it the better for search engines.
    But if you want to do it with regexp maybe you can use redirectMatch, try something like this:
    RedirectMatch 301 /(.*)$ http...domain.com/$1
    {{ DiscussionBoard.errors[5464071].message }}
    • Profile picture of the author ND
      Originally Posted by Tkato View Post

      If it's only 20 pages why don't you manually redirect them? the faster you do it the better for search engines.
      But if you want to do it with regexp maybe you can use redirectMatch, try something like this:
      RedirectMatch 301 /(.*)$ http...domain.com/$1
      Tkato,
      Thanks.
      I am not a programmer. Can you please tell me how to fit that into this code below? Which line do I replace?

      Options +FollowSymLinks
      RewriteEngine on
      RewriteRule (.*) http://www. newsite/$1 [R=301,L]
      redirect 301 /current/currentfile.html http: // www.newdomain.com/new/newfile

      thanks
      Signature
      NOVA CUSTOM PRINTING- Graphic Design, Custom Printed Labels, Stickers, T Shirts & CD/DVD Manufacturing:
      NOVA CUSTOM LABEL PRINTING, NOVA CUSTOM T SHIRT PRINTING, NOVA DISC
      {{ DiscussionBoard.errors[5469695].message }}
      • Profile picture of the author tweakr
        Here's some code that should redirect all the pages for you.

        Code:
        RewriteEngine on 
        RedirectMatch 301 (.*).html$ http://www.example.com/$1
        example.com should be set to the new domain.
        {{ DiscussionBoard.errors[5469948].message }}
        • Profile picture of the author ND
          Originally Posted by tweakr View Post

          Here's some code that should redirect all the pages for you.

          Code:
          RewriteEngine on 
          RedirectMatch 301 (.*).html$ http://www.example.com/$1
          example.com should be set to the new domain.
          no change I am afraid.
          the home page works but all others goes to
          www .NEW WEBSITE/public_html/oldpagename.html/
          resulting in a 404 page

          I want to send them from the old html pages to brand new, renamed, non-html pages.

          can anyone correct this code?

          thanks
          Signature
          NOVA CUSTOM PRINTING- Graphic Design, Custom Printed Labels, Stickers, T Shirts & CD/DVD Manufacturing:
          NOVA CUSTOM LABEL PRINTING, NOVA CUSTOM T SHIRT PRINTING, NOVA DISC
          {{ DiscussionBoard.errors[5470796].message }}
  • Profile picture of the author tweakr
    Oops, sorry I should have payed more attention when posting. I hate posting code here it always strips something out.

    Anyway, there should be a backslash before .html$, I put the code on pastebin

    Hopefully it works for you this time.
    {{ DiscussionBoard.errors[5471084].message }}
    • Profile picture of the author ND
      Originally Posted by tweakr View Post

      Oops, sorry I should have payed more attention when posting. I hate posting code here it always strips something out.

      Anyway, there should be a backslash before .html$, I put the code on pastebin

      Hopefully it works for you this time.

      Pasted exactly what you posted and it's still the same.
      what's going on?
      thanks
      Signature
      NOVA CUSTOM PRINTING- Graphic Design, Custom Printed Labels, Stickers, T Shirts & CD/DVD Manufacturing:
      NOVA CUSTOM LABEL PRINTING, NOVA CUSTOM T SHIRT PRINTING, NOVA DISC
      {{ DiscussionBoard.errors[5471743].message }}
  • Profile picture of the author tweakr
    Did you clear your browsers cache?
    {{ DiscussionBoard.errors[5472357].message }}
  • Profile picture of the author hiltonn
    a 301 Redirect is a permanent redirect which passes between 90-99% of link juice (ranking power) to the redirected page. 301 refers to the HTTP status code for this type of redirect. In most instances, the 301 redirect is the best method for implementing redirects on a website..
    {{ DiscussionBoard.errors[5472360].message }}

Trending Topics