doutang6130 2017-10-27 10:32
浏览 44

如何将wordpress主页重定向到drupal主页?

I have wordpress homepage with the link (exxample:http://online.com/wp) and drupal home page is (exxample:http://online.com/drup). for wordpress homepage alone i need to redirect to drup other than wordpress home page link should be work example: (http://online.com/wp/product-category/product1). i tried to use htaccess but it is not working

redirect 301 /wp/index.php http://online.com/drup

The above one redirect every link in worpdress. please advise me on this

  • 写回答

1条回答 默认 最新

  • dswwuo1223 2017-10-27 10:42
    关注

    You can redirect it via WordPress redirect.

    In your theme's functions file, you can write something like this:

    function homepage_redirect(){
            if( is_front_page() || is_home()  ){
                wp_redirect( 'http://online.com/drup' );
                die;
            }
        }
        add_action( 'template_redirect', 'homepage_redirect' );
    

    WordPress uses hooks and template_redirect is called just before loading appropriate template for the page, we can call the wp_redirect function here. Also that die; as last line there is to exit the WP from further execution. Details here: https://developer.wordpress.org/reference/functions/wp_redirect/

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置