.htaccess 如果URL包含特定字符串,则htaccess重定向
如果URL包含某个单词,如何编写.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
.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]