内容纲要

thinkphp程序经常用到

注意看下面规则,301规则放到了程序伪静态前面

.htaccess

<IfModule mod_rewrite.c>
选项+关注符号链接-多视图
RewriteEngine开
RewriteCond%{HTTP_HOST} ^ landui.com $ [NC]
RewriteRule ^(。*)$ http://www.landui.com/$1 [R = 301,L]
RewriteCond%{REQUEST_FILENAME}!-d
RewriteCond%{REQUEST_FILENAME}!-f
RewriteRule ^(。*)$ index.php?s = $ 1 [QSA,PT,L]
</ IfModule>

web.config

<rewrite>
<rules>
<rule name="test-301" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^landui.com$" />
</conditions>
<action type="Redirect" url="http://www.landui.com/{R:1}" redirectType="Permanent" />
</rule>
<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>

第二种方法:需配合ISAPI_Rewrite3使用

web.config放301规则

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

.htaccess放程序伪静态规则

Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

实现访问71fww.com/list/3.html时自动跳转到www.71fww.com/list/3.html

360截图20200210161543517.jpg