Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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/0/backbone.js/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 Apache将查询字符串重写为类似CodeIgniter的URL_Php_.htaccess_Codeigniter_Mod Rewrite_Query String - Fatal编程技术网

Php Apache将查询字符串重写为类似CodeIgniter的URL

Php Apache将查询字符串重写为类似CodeIgniter的URL,php,.htaccess,codeigniter,mod-rewrite,query-string,Php,.htaccess,Codeigniter,Mod Rewrite,Query String,下面是一个带有查询字符串的示例URL。关键字是用户在我的网站中搜索或从其他网站、搜索引擎等重定向的任何内容 和等效的CodeIgniter URL (搜索=控制器,现在= (方法) 如何在Apache.htaccess中重写URL以创建类似CodeIgniter的URL RewriteRule ^/?search/now/(.*)$ /search\.php?q=$1 或您可以隐藏url查询 RewriteRule ^search.php?id=(.*)$ /search.php [L,R=

下面是一个带有查询字符串的示例URL。
关键字是用户在我的网站中搜索或从其他网站、搜索引擎等重定向的任何内容

和等效的CodeIgniter URL

(搜索=控制器,现在= (方法)

如何在Apache.htaccess中重写URL以创建类似CodeIgniter的URL

RewriteRule ^/?search/now/(.*)$ /search\.php?q=$1
您可以隐藏url查询

RewriteRule ^search.php?id=(.*)$ /search.php [L,R=301]

首先,您不希望指向php文件。CI只有index.php,如果您不顾一切,可以将所有search.php指向index.php

我会在这个基础上处理它

将表单发布到控制器,使用表单验证使输入安全,获取变量并像这样使用重定向函数

redirect('/search/'.$this->input->post('q') );

你确定这就是你想要的吗?