简体   繁体   中英

How to redirect wordpress homepage to drupal home page?

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM