iis7.5配置web.config伪静态怎么写

iis7.5配置web.config伪静态怎么写,第1张

iis7.5配置web.config伪静态方法如下:

第一种方法:web.config

代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="OrgPage" stopProcessing="true">

<match url="^(.*)$" />

<conditions logicalGrouping="MatchAll">

<add input="{HTTP_HOST}" pattern="^(.*)$" />

<add input="{REQUEST_FILENAME}" matchType="IsFile"数哪 negate="true" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

</conditions>

<action type="Rewrite" url="index.php/{R:1}" />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

第二种方法:web.config

代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="规则 1" stopProcessing="true">

<match url="^includes/(.*)" />

<action type="Rewrite" url="includes\/{R:1}" />

</rule>

<rule name="规则 2" stopProcessing="true">

<match url="^(blog)/includes/(.*)" />

<action type="Rewrite" url="{R:1}/includes\/{R:2}" />

</rule>

<rule name="简隐规则 3" stopProcessing="true">

<match url="^(blog)/(.*).html(.*)" />

<action type="Rewrite" url="{R:1}/index.php\/{R:2}.html{R:3}" />

</rule>

<rule name="规则 4" stopProcessing="true">

<match url="^(.*).html(.*)" />

<action type="Rewrite" url="index.php\/{R:1}.html{R:2}" />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

下面是补充:

IIS 7和IIS 7.5及以后的版本估计都会使用web.config来实现伪静态规则,于是以前的伪静态文件必须更改。网上找了一圈,还没有发现比较全面的web.config伪静态规则,于是我们这里整理一份,供初次使用的朋友参考。

实现普通页面、带一个数字参数页面和带两个参数页面的伪静态!

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules> <rule name="Index" stopProcessing="true"><match url="^index.html" /><action type="Rewrite" url="index.php" />拦毕厅 </rule> <rule name="Rule1" stopProcessing="true"><match url="^news_([0-9]+).html" /><action type="Rewrite" url="news.php?nid={R:1}" /></rule><rule name="Rule2" stopProcessing="true"><match url="news_list_([0-9]+)_([0-9]+).html" /><action type="Rewrite" url="news_list.php?nid={R:1}&page={R:2}" /></rule> </rules></rewrite></system.webServer></configuration>

IIS 7.5通过web.config实现301重定向的方法,将不带www的域名转向到带www的域名上!

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules> <rule name="Redirect" stopProcessing="true"><match url=".*" /><conditions><add input="{HTTP_HOST}" pattern="^chuangluo.com$" /></conditions><action type="Redirect" url="http://www.chuangluo.com/{R:0}" redirectType="Permanent" /></rule> </rules></rewrite></system.webServer></configuration>

由于网站使用了转义字符,因此在实际使用的时候,大家不可以直接复制以上代码。请复制粘贴到Dreamweaver等编辑器后,使用替换功能把双引号全部替换为英文状态下的双引号,然后再修改rule标签内的内容就可以了,跳转的地方请更改为自己的网址即可。

需要注意的地方是以前httpd.ini和.htaccess支持网址中两个参数用&符号链接,在web.config中是不支持的,需要将这个符号更改为&才能正常使用。

iis7.5启用web.config伪静态方法如下:

第一种方法:web.config

. 代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="OrgPage" stopProcessing="true">

<match url="^(.*)$" />

<conditions logicalGrouping="MatchAll">

<add input="{HTTP_HOST}" pattern="^(.*)$" />

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

</conditions>轮睁

<action type="Rewrite" url="index.php/{R:1}" />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

第二种方法:web.config

. 代码腊睁岁如下:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="规则 1" stopProcessing="true">

<match url="^includes/(.*)" />

<action type="Rewrite" url="includes\/{R:1}" />

</rule>

<rule name="规则 2" stopProcessing="true">

<match url="^(blog)/includes/(.*)" />

<action type="Rewrite" url="{R:1}/includes\/{R:2}" />

</rule>

<rule name="规则 3" stopProcessing="true">

<match url="^(blog)/(.*).html(.*)" />

<action type="Rewrite" url="{R:1}/index.php\/{R:2}.html{R:3}" />

</rule>

<rule name="规则 4" stopProcessing="true">

<match url="^(.*).html(.*)" />

<action type="Rewrite"早配 url="index.php\/{R:1}.html{R:2}" />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

iis7.5配置web.config伪静态方法如下: 第一种方法:web.config 代码如下: 第二种方法:web.config 代码如下: 下面是补充: IIS 7和IIS 7.5及以后的碧氏闹版本估计都会使用web.config来实现伪静态规悔罩则,于是以前的伪核缺静态文件必须更改。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11989321.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存