【问题标题】:wordpress on shared windows hosting - enabling seo friendly permalinks and 301 redirects共享 Windows 托管上的 wordpress - 启用 seo 友好的永久链接和 301 重定向
【发布时间】:2014-08-28 09:53:19
【问题描述】:

我目前在 Windows 上托管了一个站点,该主机为我提供了 web.config 以启用对 seo 友好的永久链接(用于帖子名称)。我现在需要添加 301 重定向,但任何组合都无法正常工作,要么在我输入旧网址时导致“找不到页面”,要么导致服务器错误。我当前的 web.config(使用永久链接)是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="wordpress" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

如果我在文件中的任何位置添加它,我会收到错误

<location path="gallery.htm">
<system.webServer>
<httpRedirect enabled="true" destination="http://mydomain.co.uk/gallery" httpResponseStatus="Permanent" />
</system.webServer>
</location>

我已经尝试将其放入、移除并放入其中以及任何其他可能的组合 - 是否可以在这两个功能正常工作的情况下做到这一点?

干杯, 加里。

【问题讨论】:

    标签: wordpress iis redirect


    【解决方案1】:

    尝试将其用作您的 web.config:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <location path="gallery.htm">
    <system.webServer>
    <httpRedirect enabled="true" destination="http://mydomain.co.uk/gallery" httpResponseStatus="Permanent" />
    </system.webServer>
    </location>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="wordpress" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>
    

    让我知道这是否可行,如果不行,我会回到绘图板。

    【讨论】:

    • 我只收到“抱歉,您要查找的页面或文档似乎不存在”。当我尝试访问gallery.htm 时,主持人对此非常不公平,他们说“我应该早点提醒他们我有301 重定向,因为他们只能提供有限的支持”,除此之外,他们做得很好。
    • @Garry 我刚刚尝试在测试服务器上执行此操作,它对我来说非常有效。我敢肯定,这与您的主机设置设置的方式有关。对不起,我不能再帮忙了:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-09
    • 1970-01-01
    • 2015-12-04
    • 1970-01-01
    • 2013-08-14
    • 2016-02-11
    相关资源
    最近更新 更多