开发者

main url redirect

is it possible to have the main domain of a wordpress blog(example.com) to redirect to another site and 开发者_如何学编程the actual posts and pages (example.com/post1, example.com/about, etc') to not be redirected and instead reside on the wordpress?


add_action('init', 'redirect_home');
function redirect_home() {
  if( is_home() ) {
    wp_redirect('http://example.com');
  }
}

That should do it.


You could do that with mod_rewrite:

RewriteEngine on
RewriteRule ^$ http://other.example.com/ [L,R]

This example is for the .htaccess file in the document root directory and will redirect requests to other.example.com.


You could also look at using the WordPress redirection function in place of the header location..

wp_redirect('someurl', 301);

301 is the status code to use, and of course someurl is where you'd place your URL to reirect to.. (301 is default, so not required unless you want a difference status code)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜