php - Codeigniter URL redirection and routing -


I am trying to redirect URL with codicular routing. I can not write writing for the following

If the URL comes with / api / some / some then I'll call it api / some / some , otherwise I can copy the URL to / I want to redirect to home / index .

That means if a URL starts with api / , then I do not want other intelligent users to change that URL, because I want it to be the default controller home / index

which tries to map the codeinator URL routing.

  $ route ['API / (: any)'] = 'API / (: any)'; $ Route ['(: any)'] = 'home / index' ';   

I'm trying with codeigniter URL routing technology but I am not able to get it.

Does the URL redirect to the codeigner level with the compression server side redirection or is there a better way to do this?

Solution 1. Using Codeigner Routing

View it in your application / config / routes.php $ route ['API / (: any)'] = "API / $ 1"; $ Route ['(: any)'] = "home / index / $ 1"; $ Route ['default_controller'] = "home";

  1. In a () fashion for a match, you must add the related $ 1 or $ 2 , $ 3 .. Based on that condition, () patter first () its $ 1, second () for its $ 2 and so on.

  2. You need to set your default controller to Home .

    Solution 2. Using .htaccess page redirection Reviving OnReitRound code% {REQUEST_URI}! ^ / Api (. *) $ Rewrite% {REQUEST_URI}! ^ / home / index $ RewriteRule ^. * $ / home / index [R = 301, QSA, L]

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -