Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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 CodeIgniter.htacces上的URL重写规则_Php_Regex_.htaccess_Codeigniter_Url Rewriting - Fatal编程技术网

Php CodeIgniter.htacces上的URL重写规则

Php CodeIgniter.htacces上的URL重写规则,php,regex,.htaccess,codeigniter,url-rewriting,Php,Regex,.htaccess,Codeigniter,Url Rewriting,我有以下网址: http://<site>/assets-teste/... 在我看来,你在使用CodeIgniter。他们的系统内置了路由,我建议用它来改变你的URL方案 首先,你(我)应该使用下划线\uu字符作为空格,而不是- RewriteRule的第一部分说明了在URL中找到要重写的内容 在URL中本地化: ^\/assets-teste\/(.*) 正在写入新的url: /application/views/ambiente_teste/assets-teste/$1

我有以下网址:

http://<site>/assets-teste/...

在我看来,你在使用CodeIgniter。他们的系统内置了路由,我建议用它来改变你的URL方案

首先,你(我)应该使用下划线
\uu
字符作为空格,而不是
-

RewriteRule
的第一部分说明了在URL中找到要重写的内容

在URL中本地化:

^\/assets-teste\/(.*)
正在写入新的url:

/application/views/ambiente_teste/assets-teste/$1
而.htaccess将如下所示:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^\/assets-teste\/(.*) /application/views/ambiente_teste/assets-teste/$1 [L]

附加说明:

将启用重写引擎:

RewriteEngine On
重写的基本目录为/:

RewriteBase /
如果请求与不存在的文件匹配,请继续:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
如果请求与不存在的目录匹配,请继续:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

[L]
立即停止重写过程,不要再应用任何规则。

那么您想将其重写到
/assets teste/application/views/ambiente\u teste/
?还是要完全删除
/application/views/ambiente\u teste/
?嘿,kkkk。确切地说,我想将
/application/views/ambiente\u teste/assets teste/
重写为simple
/assets teste/
。或者只是删除
/application/views/ambiente_teste/
哦,这是真的,但我不知道如何使用routes.php向这个文件夹添加直接路由,所以你能帮我吗?在application/config/routes.php下,添加以下内容:
$route['assets-teste/']=“controller\u name/method”基本上,您使用$route数组,并添加一个用作所需URI的键,然后将该值设置为用于呈现该页面的方法。下面是一段关于CI中路由的精彩视频: