zl程序教程

您现在的位置是:首页 >  硬件

当前栏目

(六)RewriteCond 调用服务器变量 TestString使用说明%1-9

服务器变量 说明 调用 使用
2023-09-27 14:27:48 时间

TestString 使用说明 %{NAME_OF_VARIABLE}

 服务器变量引用

RewriteCond %{HTTM_HOST} "127.0.0.1"

 

用法 编写规则

RewriteEngine on
RewriteCond %{HTTP_HOST} "127.0.0.1"
RewriteRule ^(.*).htm http://localhost/$1.html [R]

当访问127.0.0.1/testaa.htm时候 地址栏会变成http://localhost/taest.html

TestString 使用说明 %1-9

%1-9 RewriteCond条件中最后符合的条件中的分组成分

RewriteEngine on
RewriteCond %{HTTP_HOST} "127.0.0.(.*)"
RewriteCond %1 "2"
RewriteRule ^(.*).htm http://localhost/$1.html [R]

当访问127.0.0.1/testaa.htm时候 地址栏不会变成http://localhost/taest.html

RewriteEngine on
RewriteCond %{HTTP_HOST} "127.0.0.(.*)"
RewriteCond %1 "1"
RewriteRule ^(.*).htm http://localhost/$1.html [R]

 

当访问127.0.0.1/testaa.htm时候 地址栏会变成http://localhost/taest.html

%1 是去中最后条件中的组成部分 就是1~~~