Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   SEO and 301 Redirect code (https://www.warriorforum.com/programming/523859-seo-301-redirect-code.html)

ND 16th January 2012 03:49 PM

SEO and 301 Redirect code
 
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

tweakr 17th January 2012 06:35 AM

Re: SEO and 301 Redirect code
 
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

frenchsquared 17th January 2012 08:29 AM

Re: SEO and 301 Redirect code
 
Quote:

Originally Posted by tweakr (Post 5441182)
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.

ND 19th January 2012 06:26 PM

Re: SEO and 301 Redirect code
 
Quote:

Originally Posted by tweakr (Post 5441182)
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!

ND 20th January 2012 08:10 PM

Re: SEO and 301 Redirect code
 
can anyone help me with this please? It's urgent because this website has been offline for 3 days!
thank you

Tkato 21st January 2012 12:25 PM

Re: SEO and 301 Redirect code
 
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

ND 22nd January 2012 02:46 PM

Re: SEO and 301 Redirect code
 
Quote:

Originally Posted by Tkato (Post 5464071)
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

tweakr 22nd January 2012 03:51 PM

Re: SEO and 301 Redirect code
 
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.

ND 22nd January 2012 07:51 PM

Re: SEO and 301 Redirect code
 
Quote:

Originally Posted by tweakr (Post 5469948)
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

tweakr 22nd January 2012 09:17 PM

Re: SEO and 301 Redirect code
 
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.

ND 23rd January 2012 12:23 AM

Re: SEO and 301 Redirect code
 
Quote:

Originally Posted by tweakr (Post 5471084)
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

tweakr 23rd January 2012 03:27 AM

Re: SEO and 301 Redirect code
 
Did you clear your browsers cache?

hiltonn 23rd January 2012 03:28 AM

Re: SEO and 301 Redirect code
 
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..


All times are GMT -6. The time now is 08:46 AM.