SEO and 301 Redirect code

by 12 replies
14
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
#programming #301 #code #redirect #seo
  • 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
    • [2] replies

    • 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.
    • 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!
      • [1] reply
  • 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
    • [1] reply
    • 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
      • [1] reply
  • 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.
    • [1] reply

    • Pasted exactly what you posted and it's still the same.
      what's going on?
      thanks
  • [DELETED]
  • Did you clear your browsers cache?
  • 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..

Next Topics on Trending Feed