Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.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 在Codeigneter项目上重写Htaccess Url_Php_Apache_.htaccess_Codeigniter - Fatal编程技术网

Php 在Codeigneter项目上重写Htaccess Url

Php 在Codeigneter项目上重写Htaccess Url,php,apache,.htaccess,codeigniter,Php,Apache,.htaccess,Codeigniter,我可以将此url(例如此参数值)转换为此url吗 参数值是否使用.htaccess 我不知道如何使用htaccess实现这一点,但您可以使用routes.php(在config文件夹中)文件实现这一点 像这样: $route['(\d+)'] = "controller_name/method_name/$1/"; $1是url的十进制参数 如果需要将字符串作为参数传递,请尝试以下操作: $route['([a-z-]+)'] = "controller_name/method_name/$1

我可以将此url(例如此参数值)转换为此url吗
参数值是否使用.htaccess

我不知道如何使用htaccess实现这一点,但您可以使用routes.php(在config文件夹中)文件实现这一点

像这样:

$route['(\d+)'] = "controller_name/method_name/$1/";
$1是url的十进制参数

如果需要将字符串作为参数传递,请尝试以下操作:

$route['([a-z-]+)'] = "controller_name/method_name/$1/";
而$1将是url中的字符串

例如,如果您有控制器主页,并且有:

public function methodname($parameter) {}
使用如下路由:

$route['([a-z-]+)'] = "home/methodname/$1/";
在url:example.com/this_is_参数中
在方法methodname将是$parameter=“this_is_parameter”

由于我是codeigneter新手,您能给我更多详细信息吗Daniel?application/config/routes.php将此代码放在这个文件中,并更改控制器名和方法名上的“controller_name”在你的方法名称上,我编辑了我的答案,向上看,你救了我,谢谢Daniel,你真是太好了:)对不起,我没有15个人的声誉来证实这个回答,真的很抱歉,我不知道,希望我能帮到你