Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.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
Regex HTACCESS始终重定向到/_Regex_Apache_.htaccess_Codeigniter_Mod Rewrite - Fatal编程技术网

Regex HTACCESS始终重定向到/

Regex HTACCESS始终重定向到/,regex,apache,.htaccess,codeigniter,mod-rewrite,Regex,Apache,.htaccess,Codeigniter,Mod Rewrite,我需要始终重定向到/。 例如,如果我的URL是,它应该重定向到(所有的斜杠都应该删除,只留下一个)。怎么做?我正在使用CodeIgniter,我的.htaccess: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{REQUEST_URI} syst

我需要始终重定向到/。 例如,如果我的URL是,它应该重定向到(所有的斜杠都应该删除,只留下一个)。怎么做?我正在使用CodeIgniter,我的.htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI}  [R=301,L] 

RewriteCond %{REQUEST_URI} system|application
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
   Header set Cache-Control "max-age=604800, public"
</FilesMatch>
重新编写引擎打开
重写基/
重写cond%{HTTP_HOST}^www\。[北卡罗来纳州]
重写规则^http://www.%{HTTP_HOST}%{REQUEST_URI}[R=301,L]
重写COND%{REQUEST_URI}系统|应用程序
重写规则^(.*)$index.php?/$1[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
标题集缓存控制“最大年龄=604800,公共”

将此规则置于其他规则之前的顶部

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)/{2,}[?\s] [NC]
RewriteRule ^ /%1/ [L,R=301]

将此规则置于其他规则之前的顶部

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)/{2,}[?\s] [NC]
RewriteRule ^ /%1/ [L,R=301]

尝试在
RewriteBase/
的正下方添加此选项:

RewriteCond %{THE_REQUEST} \ /+([^\ \?]+?)/{2,}([^\ \?]*)
RewriteRule ^ /%1/%2 [L,R=301]

尝试在
RewriteBase/
的正下方添加此选项:

RewriteCond %{THE_REQUEST} \ /+([^\ \?]+?)/{2,}([^\ \?]*)
RewriteRule ^ /%1/%2 [L,R=301]

不,“标签”只是一个例子,我的链接可以是
http://link.com/tag/antother_uri/the_other_segment//// 
http://link.com/tag/the_other_segment///////////////
否,“标签”只是一个示例,我的链接可以是
http://link.com/tag/antother_uri/the_other_segment//// 
http://link.com/tag/the_other_segment///////////////
可以,但是如果我的url是
http://link.com/uri1/uri2/uri3///////////////////////
我看到错误,重定向循环是无限的,可以工作,但是如果我的url是
http://link.com/uri1/uri2/uri3///////////////////////
我看到错误,重定向周期为无穷大