Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用属性incodeigner替换控制器和函数名?_Php_.htaccess_Codeigniter_Routing_Routes - Fatal编程技术网

Php 用属性incodeigner替换控制器和函数名?

Php 用属性incodeigner替换控制器和函数名?,php,.htaccess,codeigniter,routing,routes,Php,.htaccess,Codeigniter,Routing,Routes,在htaccess或route.php中,从您想要的位置可以给出此问题的答案 我需要这样的东西。如果我有url: http://tageto.pnf-sites.info/developer/headcategory_controller/head_category/Agriculture 必须将其替换为 http://tageto.pnf-sites.info/developer/Agriculture http://tageto.pnf-sites.info/developer/Agri

在htaccess或route.php中,从您想要的位置可以给出此问题的答案

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

http://tageto.pnf-sites.info/developer/headcategory_controller/head_category/Agriculture
必须将其替换为

http://tageto.pnf-sites.info/developer/Agriculture
http://tageto.pnf-sites.info/developer/Agriculture/Rice
如果我有这样的url

http://tageto.pnf-sites.info/developer/headcategory_controller/sub_category/Rice
必须将其替换为

http://tageto.pnf-sites.info/developer/Agriculture
http://tageto.pnf-sites.info/developer/Agriculture/Rice
有人能解决我的这个问题吗?请尽快回复

.htaccess

 <IfModule mod_rewrite.c>

RewriteEngine On

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

</IfModule>

重新启动发动机
重写规则^(开发者)/[^/]+/[^/]+/(.+)$/$1/$2[NC,L,R=302]

通过此->错误404-未找到

在您的
文档\u 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';

在第二个url示例中,您想要农业,但我看不出它在完整url中的位置。这是返回大米的结果查询的一部分?好的,在这里我必须添加代码以获得“农业”首先没问题。但是先生,我如何管理类名和函数名,使其成为一个干净的url,只显示类别或类别/子类别。如果您想尝试非路由/htaccess选项,您可以在控制器中尝试查找函数。首先,感谢您的帮助,对不起,先生,当我替换.htaccess文件时,它会给出404错误。这会将
/developer/headcategory\u controller/head\u category/Agriculture
重定向到
/developer/Agriculture
,这不是为您发生的吗?不,先生,当我替换我项目的.htaccess中的代码时,您给我的,它会给出404找不到的页面一定要把这个规则放在你们所有其他规则之前好的,非常感谢,先生,你们太好了。就像你们喜欢修复编程错误的方式一样。