您的位置 首页 > 数码极客

IIS伪静态如何去掉index开头

IIS7.5不自带URL Rewrite模块,所以,当WordPress设置伪静态时,可能会出现“HTTP 错误 404.0 - Not Found”的问题。

今天,小小课堂SEO自学网为大家带来的是《Windows Server 2008 IIS7.5 为WordPress设置伪静态》的解决办法。希望对大家有所帮助。

一、WordPress设置伪静态出错

WP伪静态是需要设置的,马慧SEO认为默认的URL链接形式并不友好。

合理的应该为:栏目末尾有斜杠,页面末尾有.html。

① 斜杠

这段代码加到 主题文件的中即可解决。

function nice_trailingslashit($string, $type_of_url) {

if ( $type_of_url != 'single' && $type_of_url != 'page' && $type_of_url != 'single_paged' )

$string = trailingslashit($string);

return $string;

}

add_filter('user_trailingslashit', 'nice_trailingslashit', 10, 2);

② 末尾.html

文章末尾加.html的方法,直接设置固定链接-自定义结构即可,这样设置完成之后,文章页面的URL就变成了.html了,但单页面还是没有html,个人认为这样的效果就可以了。单页面URL与文章不同也是可以的。

/%category%/%post_id%.html

但是设置完成后,可能就会出现以下错误:

HTTP 错误 404.0 - Not Found 您要找的资源已被删除、已更名或暂时不可用。

指定的目录或文件在 Web 服务器上不存在。

URL 拼写错误。

某个自定义筛选器或模块(如 URLScan)限制了对该文件的访问。

模块 IIS Web Core

通知 MapRequestHandler

处理程序 StaticFile

错误代码 0x80070002

二、URL Rewrite模块下载与安装

Windows 2008的服务器一般为IIS7.5,不自带URL Rewrite模块,所以,需要先去微软官网下载。x86适合32位系统,x64适合64位系统。

将文件下载下来之后,直接上传至服务器就可以进行安装了,安装完成之后,记得重启一次就好。

另外,别再官方下载错了哦~

三、最后的操作-修改web.config

增加内容如下:

<rule name="WordPress: " patternSyntax="Wildcard">

<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.php" />

</rule>

<rule name="WordPress Rule 1" stopProcessing="true">

<match url="^index\.php$" ignoreCase="false" />

<action type="None" />

</rule>

<rule name="WordPress Rule 2" stopProcessing="true">

<match url="^wp-admin$" ignoreCase="false" />

<action type="Redirect" url="wp-admin/" redirectType="Permanent" />

</rule>

<rule name="WordPress Rule 3" stopProcessing="true">

<match url="^" ignoreCase="false" />

<conditions logicalGrouping="MatchAny">

<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />

</conditions>

<action type="None" />

</rule>

<rule name="WordPress Rule 4" stopProcessing="true">

<match url="^(wp-(content|admin|includes).*)" ignoreCase="false" />

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

</rule>

<rule name="WordPress Rule 5" stopProcessing="true">

<match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />

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

</rule>

<rule name="WordPress Rule 6" stopProcessing="true">

<match url="." ignoreCase="false" />

<action type="Rewrite" url="index.php" />

</rule>

以上就是小小课堂SEO自学网为大家带来的是《Windows Server 2008 IIS7.5 为WordPress设置伪静态》的解决办法。感谢您的观看。

喜欢记得,点赞,打赏哦。小小课堂SEO自学网,每天一个SEO原创视频和图文教程,别忘了关注哦。

更多seo教程搜索小小课堂。原创文章欢迎转载并保留版权:

/jianzhanjiaocheng/

责任编辑: 鲁达

1.内容基于多重复合算法人工智能语言模型创作,旨在以深度学习研究为目的传播信息知识,内容观点与本网站无关,反馈举报请
2.仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证;
3.本站属于非营利性站点无毒无广告,请读者放心使用!

“IIS伪静态如何去掉index开头”边界阅读