开发者

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/wha开发者_运维技巧tever
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


Use the Redirect directive:

Redirect / http://blabla.net/

This directive automatically preserves anything specified after the /.


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.


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜