本日志标题:站点伪静态,把域名二级目录重定向到二级域名        [2023-1-3]

博客之前用的是主站域名下的二级目录,即blog目录是用来访问博客的, www.cnbruce.com/blog

现在开始跳转博客的域名,采用了一个二级域名 blog.cnbruce.com ,但很多的外部链接,包括搜索引擎检索的结果,也需要能自动切换。

目标是 原有的博客地址能自动跳转到新的二级域名下的地址,比如 www.cnbruce.com/blog/show.asp?id=xcd 应该能自动跳转到 blog.cnbruce.com/show.asp?id=xcd

只需要在主域名 www.cnbruce.com 下面做下站点的伪静态。


rewrite ^(.*)/blog/(.*) https://blog.cnbruce.com/$2 permanent;



===========

把blog的动态地址伪静态成静态地址



根目录下的web.config文件



<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^index\.asp$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^vt=([^=&amp;]+)&amp;cat_id=([^=&amp;]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.asp?vt={R:1}&amp;cat_id={R:2}" />
</rule>
<rule name="RedirectUserFriendlyURL2" stopProcessing="true">
<match url="^showlog\.asp$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^cat_id=([^=&amp;]+)&amp;log_id=([^=&amp;]+)$" />
</conditions>
<action type="Redirect" url="showlog/{C:1}/{C:2}.html" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL2" stopProcessing="true">
<match url="^showlog/([^/]+)/([^/]+)\.html" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="showlog.asp?cat_id={R:1}&amp;log_id={R:2}" />
</rule>
<rule name="RedirectUserFriendlyURL3" enabled="true" stopProcessing="true">
<match url="^index\.asp$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^vt=([^=&amp;]+)&amp;l_year=([^=&amp;]+)$" />
</conditions>
<action type="Redirect" url="year/{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL3" enabled="true" stopProcessing="true">
<match url="^year/([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.asp?vt={R:1}&amp;l_year={R:2}" />
</rule>
<rule name="RedirectUserFriendlyURL4" enabled="true" stopProcessing="true">
<match url="^index\.asp$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^vt=([^=&amp;]+)&amp;page=([^=&amp;]+)$" />
</conditions>
<action type="Redirect" url="page/{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL4" enabled="true" stopProcessing="true">
<match url="^page/([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.asp?vt={R:1}&amp;page={R:2}" />
</rule>
<rule name="RedirectUserFriendlyURL5" enabled="true" stopProcessing="true">
<match url="^index\.asp$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^vt=([^=&amp;]+)&amp;cat_id=([^=&amp;]+)&amp;page=([^=&amp;]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}/{C:3}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL5" enabled="true" stopProcessing="true">
<match url="^([^/]+)/([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.asp?vt={R:1}&amp;cat_id={R:2}&amp;page={R:3}" />
</rule>
<rule name="redirect to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^(.*/)index\.asp\?vt=([^=&amp;]+)&amp;(?:amp;)?cat_id=([^=&amp;]+)$" />
<action type="Rewrite" value="{R:1}{R:2}/{R:3}/" />
</rule>
<rule name="OutboundRewriteUserFriendlyURL2" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form" pattern="^(.*/)showlog\.asp\?cat_id=([^=&amp;]+)&amp;(?:amp;)?log_id=([^=&amp;]+)$" />
<action type="Rewrite" value="{R:1}showlog/{R:2}/{R:3}.html" />
</rule>
<rule name="OutboundRewriteUserFriendlyURL6" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form" pattern="^(.*/)showlog\.asp\?log_id=([^=&amp;]+)$" />
<action type="Rewrite" value="{R:1}showlog/0/{R:2}.html" />
</rule>
<rule name="OutboundRewriteUserFriendlyURL3" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^(.*/)index\.asp\?vt=([^=&amp;]+)&amp;(?:amp;)?l_year=([^=&amp;]+)$" />
<action type="Rewrite" value="{R:1}/year/{R:2}/{R:3}/" />
</rule>
<rule name="OutboundRewriteUserFriendlyURL4" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^(.*/)index\.asp\?vt=([^=&amp;]+)&amp;(?:amp;)?page=([^=&amp;]+)$" />
<action type="Rewrite" value="https://blog.cnbruce.com/page/{R:2}/{R:3}/" />
</rule>
<rule name="OutboundRewriteUserFriendlyURL5" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^(.*/)index\.asp\?vt=([^=&amp;]+)&amp;(?:amp;)?cat_id=([^=&amp;]+)&amp;(?:amp;)?page=([^=&amp;]+)$" />
<action type="Rewrite" value="{R:1}{R:2}/{R:3}/{R:4}/" />
</rule>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>

</configuration>


在百度搜索完整的站点伪静态,把域名二级目录重定向到二级域名内容,或者用Google搜索相关的更多内容

By [cnbruce] at 11:39:10 | 评论 [0] | 浏览 [700] | TrackBack| 返回顶部

About Comments
此篇日志暂时没有相关的说明和评论。:)


Post a Comment
呢称: 验证码: 
禁止笑脸转换 禁止UBB | 缩放输入框:6 5 | [Ctrl+Enter提交](1000个字符限制)