简体   繁体   English

Wordpress、IIS7、永久链接和 index.php

[英]Wordpress, IIS7, Permalinks and index.php

I know this question may have been asked before, but I have read hundreds of posts all over the Internets and nothing has worked...我知道这个问题之前可能已经被问过,但我已经阅读了互联网上的数百篇帖子,但没有任何效果......

I have a wordpress install (WP 3.0), running on MySQL and PHP 5.2.6.我有一个 wordpress 安装(WP 3.0),在 MySQL 和 PHP 5.2.6 上运行。

I'm trying to get the permalinks to just be site.com/postname.我试图让永久链接成为 site.com/postname。 When I set the permalinks in the settings to just be当我将设置中的永久链接设置为

/%postname%

It displays as I want it, but I get a 404 on every page (other than the home page).它按我想要的方式显示,但我在每个页面(除了主页)上都得到 404。

When it's in this state, if I manually type in site.com/index.php/postname, I get the page, but all the links on the site are pointing to site.com/postname, leading to 404s...当它处于这种状态时,如果我手动输入site.com/index.php/postname,我得到了页面,但是该站点上的所有链接都指向site.com/postname,导致404...

I've been all round the houses on this one, and got in to several different situations.我一直在这个房子周围,并遇到了几种不同的情况。 At one point, all the links were going to site.com/postname, and instead of 404'ing, they were all just displaying the home page content在某一时刻,所有链接都指向 site.com/postname,而不是 404,它们都只是显示主页内容

You need to do URL rewriting.您需要进行 URL 重写。 This is usually done in the .htaccess file for your site.这通常在您站点的 .htaccess 文件中完成。 On IIS you need a third party plugin to provide this functionality.在 IIS 上,您需要第三方插件来提供此功能。

Here is my .htaccess from my IIS/WP3 blog, were I host under /blog/ which you could remove from below:这是我的 IIS/WP3 博客中的 .htaccess,我是否在 /blog/ 下托管,您可以从下面删除:

php_value memory_limit 48M
Options +FollowSymlinks

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/.* /blog/index.php [NC,L]

IIS doesn't support a .htaccess file, but you can use the 'URL Rewrite' module to achieve the same pretty urls. IIS 不支持 .htaccess 文件,但您可以使用“URL Rewrite”模块来实现相同的漂亮 url。

This article (from 2008) describes how it works.这篇文章(从 2008 年开始)描述了它是如何工作的。 The URL rewrite module is available in the web platform installer , as it is a Microsoft add on for IIS (not specific for Wordpress). URL 重写模块在web 平台安装程序中可用,因为它是 IIS 的 Microsoft 附加组件(不是特定于 Wordpress)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM