简体   繁体   中英

How to redirect the user to a specific URL, on visiting the homepage?

I want to redirect the user when he visits the homepage.

So if he goes to example.com, Of course if there is http,https,www or visiting from google, He should be redirected to example.com/#element .

I can't use:

header()

Because the website is built with CodeIgniter and I can't get the right php file.

Either:

window.location

As I don't want to rely on the client side.

$this->load->helper('url');   
redirect('/controller/function/', 'refresh');

use this code in index function of your home controller

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