CodeIgniter with encrypted URLs

微笑、不失礼 提交于 2021-02-05 06:42:08

问题


I want to use codeigniter framework for my project but I dont want it readable, so i have to encrypt url like:

http://myproject.com/index.php/indexcontroller/myaction/

into:

http://myproject.com/as79d8a7sd9a8sd7a98d7a9s8d790akmwmwm97aw

I dont know how to achieve such scenario. How controller and methods will be called and how it will be performed. Please guide me.


回答1:


This sounds like a job for URI routing!

Add this to your config/routes.php:

$route['(:any)'] = "MyController/MyFunc/$1";

Now when you go to:

http://myproject.com/as79d8a7sd9a8sd7a98d7a9s8d790akmwmwm97aw

it will be "redirected" to:

http://myproject.com/MyController/MyFunc/as79d8a7sd9a8sd7a98d7a9s8d790akmwmwm97aw

From there, you can "decode" the URL, and redirect to where you want to go.




回答2:


you can solve this problem by play with: application/config/routes.php

$route['(:any)'] = "controller/myaction/$1";

for more information URI Routing documination



来源:https://stackoverflow.com/questions/10623374/codeigniter-with-encrypted-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!