简体   繁体   中英

rewrite or redirect to curent page in codeigniter

hello guys i want to ask if there possible to rewrite or redirect to current page url if we are change our link page by manual in link bar?

example :

our current link is www.example.com/example/data-data/link-link

than im change that current link in the link bar become :

www.example.com/example/data-data/link-li

than

if the link was changed will be

redirect to www.example.com/example/data-data/link-link

if it is possible please guide me how to do it

thank you

Yes it is possible to do, all you have to do is follow the steps

  1. Change your routes.php file as following (Replace 404_override with Errors controller's index method)

     $route['404_override'] = 'errors/index'; 
  2. Now create a Errors controller with index method in your controllers directory with following code

     defined('BASEPATH') OR exit('No direct script access allowed'); class Errors extends CI_Controller { public function index() { redirect($this->router->fetch_class()); } } 

Now when you will browse any wrong link it will redirect you to corresponding controller from where you mistype.

Yes It is possible in codeigniter you only need to make route for this link after that you can redirect where ever you want.

In codeigniter version 3 :-

File is located in :- application\\config\\routes.php

make your route and give which controller you want to run.

$route['example/data-data/link-li'] = 'your controller name';

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