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";
-
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.
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
Post a Comment