Permanent Redirect

  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6810
  • Loc: Martinsburg, WV

Post 3+ Months Ago

Been searching Google for this for a bit and not finding anything clear so I figured I would ask here.

Say I want to redirect everything that appears at http://oldsite/content/ to http://newsite/content

Say there is about 50 pages in the content directory and I'd want http://oldsite/content/page1 to redirect to http://newsite/content/page1

Is there a simple way to do this? I've seen this during my google searching:

Code: [ Select ]
Redirect 301 /old-file.html http://www.domain.com/new-file.html


Would

Code: [ Select ]
Redirect 301 /content/* http://newsite/content/


work?

Any ideas and suggestions welcome.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9102
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

There are a few ways you could do this, you could use the Redirect command like you are using, or you could use a RewriteRule. Using the Redirect method I think it would just be this:

Code: [ Select ]
Redirect 301 /content http://newsite/content


I usually use RewriteRules though, you need the mod_rewrite module with Apache. It would be something like this then:

Code: [ Select ]
RewriteEngine on
RewriteCond %{HTTP_HOST} !^newsite\.com
RewriteRule ^\/content\/(.*)$ http://www.newdomain.com/content/$1 [R=301,L]
  1. RewriteEngine on
  2. RewriteCond %{HTTP_HOST} !^newsite\.com
  3. RewriteRule ^\/content\/(.*)$ http://www.newdomain.com/content/$1 [R=301,L]


Hope that helps!

Brian
  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6810
  • Loc: Martinsburg, WV

Post 3+ Months Ago

Thanks, that does help and will see how it goes.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

I don't know if this is solved or not, but if all of those links are relative links then you could use base href.

HTML Code: [ Select ]
<base href="http://www.newsite.com">

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.