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
.htaccess 如果URL包含特定字符串,则htaccess重定向_.htaccess - Fatal编程技术网

.htaccess 如果URL包含特定字符串,则htaccess重定向

.htaccess 如果URL包含特定字符串,则htaccess重定向,.htaccess,.htaccess,如果URL包含某个单词,如何编写.htaccess重定向规则 e、 g.如果它包含foobar,则重定向到index.php RewriteCond %{REQUEST_URI} foobar RewriteRule .* index.php 或者 (网站内没有空间)如果url包含证书字符串,请重定向到index.php。您需要匹配%{REQUEST\u URI}变量,以检查url是否包含certen字符串 要将example.com/foo/bar重定向到/index.php,如果uri在u

如果URL包含某个单词,如何编写
.htaccess
重定向规则

e、 g.如果它包含
foobar
,则重定向到
index.php

RewriteCond %{REQUEST_URI} foobar
RewriteRule .* index.php
或者


(网站内没有空间)

如果url包含证书字符串,请重定向到index.php。您需要匹配%{REQUEST\u URI}变量,以检查url是否包含certen字符串

要将example.com/foo/bar重定向到/index.php,如果uri在uri字符串的任何位置包含bar,可以使用以下命令:

RewriteEngine on

RewriteCond %{REQUEST_URI} bar
RewriteRule ^ /index.php [L,R]

谢谢你的快速回复。工作完美,但刚刚实现,而不是重写,我需要它重定向。这可能吗?如何获取参数(例如$1)?,重写规则^(.*)foobar(.*)$/foobar/index.php?q=$1[L],不获取任何参数。
RewriteRule ^(.*)foobar(.*)$ http://www.example.com/index.php [L,R=301]
RewriteEngine on

RewriteCond %{REQUEST_URI} bar
RewriteRule ^ /index.php [L,R]