Alex
Alex

Reputation: 68004

How to redirect a site to a new site

I have a site which has pages like this:

blabla.com/page/whatever
blabla.com/category/whatever
blabla.com/about
...

How can I redirect each of these to a new domain, like:

blabla.net/page/whatever
blabla.net/category/whatever
blabla.net/about
...

?

Using .htaccess

Upvotes: 2

Views: 91

Answers (3)

user3092121
user3092121

Reputation: 16

Or if you use nginx (like we at http://applehub.us, http://crazyfootball.net etc)

location ~ ^/.*_sitemap([\d]+)?.(xml|xml.gz)$ {
  rewrite /(.*) /$1 break;
  proxy_pass http://yourupstrem;
}

Upvotes: 0

mgiuca
mgiuca

Reputation: 21357

It might take a bit of fiddling, but the basic idea should work here:

RewriteEngine on
RewriteRule ^(.+)$ http://blabla.net/$1 [R,NC]

You need to have mod_rewrite installed in Apache.

This says "match all URLs on this site, and redirect them to http://blabla.net/the same URL. The [R] means to actually send a redirect request to the client (so the client will make the request to the new server), rather than just serving up the page but keeping the browser URL the same. You can take the R out if you just want to serve the page but keep the old URL.

Upvotes: 1

Greg Hewgill
Greg Hewgill

Reputation: 993183

Use the Redirect directive:

Redirect / http://blabla.net/

This directive automatically preserves anything specified after the /.

Upvotes: 3

Related Questions