用属性隐姓埋名替换控制器和函数名称


Replacing Controller and function name with attribute incodeigniter?

在htaccess或route.php中,您可以从哪里给出这个问题的答案。

我需要这样的东西。如果我有网址:

http://tageto.pnf-sites.info/developer/headcategory_controller/head_category/Agriculture

则必须将其替换为

http://tageto.pnf-sites.info/developer/Agriculture

如果我有这样的网址

http://tageto.pnf-sites.info/developer/headcategory_controller/sub_category/Rice

则必须将其替换为

http://tageto.pnf-sites.info/developer/Agriculture/Rice

有人能解决我的这个问题吗?请迅速回复。

.htaccess

 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(developer)/[^/]+/[^/]+/(.+)$ /$1/$2 [NC,L,R=302]
</IfModule>

通过这个->错误404-找不到!

DOCUMENT_ROOT/.htaccess文件中尝试此规则:

RewriteEngine On
RewriteRule ^(developer)/[^/]+/[^/]+/(.+)$ /$1/$2 [NC,L,R=302]

您可以在htaccess中尝试以下操作

 RewriteCond %{HTTPS} on
 RewriteRule ^developer/headcategory_controller/sub_category/Rice  http://%{SERVER_NAME}%{REQUEST_URI} [R,L]

您可以尝试此rout.php

$route['developer/Agriculture/(:any)'] = 'developer/headcategory_controller/sub_category/$1';