如何使用 WordPress 配置 Windows Azure 以进行 URL 重写? [英] How Do You Configure Windows Azure For Url Rewrite Using WordPress?

查看:10
本文介绍了如何使用 WordPress 配置 Windows Azure 以进行 URL 重写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用 Windows Azure 和他们的 WordPress 博客模板创建了一个网站.我能够更新 CNAME 和别名记录以正确地将我的域转发到他们的网站.当我访问:www.myblog.net 时,我被重定向到:myblog.azurewebsites.net 并且浏览器显示 www.myblog.net,这正是我想要的.

I have just created a website using Windows Azure and their template for a WordPress blog. I was able to update the CNAME and Alias records to properly forward my domain to their website. When I go to: www.myblog.net, I am redirected to: myblog.azurewebsites.net and the browser shows www.myblog.net, which is what I want.

这一切正常.该网站加载良好,一切都很好.

This all works fine. The site loads fine and all is well.

但是,当我尝试访问带有固定链接的页面时,问题就出现了.通过 WordPress 配置,我将我的永久链接更新为以下格式:http://www.myblog.net/blog/The-Post-Name-Is-Here.问题在于,当我尝试访问该 URL 时,出现以下错误:

The problem, though, comes when I try to get to a page with a permalink. Through WordPress configuration, I updated my permalinks to be in this format: http://www.myblog.net/blog/The-Post-Name-Is-Here. The problem with this is that when I attempt to go to that URL, I get this error:

您要查找的资源已被删除、更名或暂时不可用.

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

如果我转到同一主题的短链接(例如 http://www.myblog.net/?p=241),页面已找到,一切正常.

If I go to the shortlink for that same topic (e.g. http://www.myblog.net/?p=241), the page is found and all is well.

我对此进行了大量研究,并发现 apache 有一个 url 重写,但这显然对我不起作用.我还发现 IIS 有一个 url 重写,我在本地玩过这个.您可以配置它以正确管理 url 重写.但是,Windows Azure 网站配置门户中没有这样的 IIS 面板.

I have researched this quite a lot and have found that there is a url rewrite for apache, but that obviously won't work for me. I have also found that there is a url rewrite for IIS and I have played with this locally. You can configure this to properly manage the url rewrite. However, there is no such IIS panel in the Windows Azure Websites configuration portal.

我还阅读了很多关于编辑 web.config 和 htaccess 的文章,但这些文件都不在我的 azure 网站的 wwwroot 目录(或任何子目录)中.

I have also read a lot about editing web.config and htaccess, but neither of these files are in my wwwroot directory (or any child directories) for my website on azure.

那么,有谁知道如何配置 azure 网站以正确管理永久链接?

So, does anyone know how to configure azure websites to manage permalinks properly?

预先感谢您的帮助!

推荐答案

Windows Azure 网站上的 WordPress 在 Microsoft Internet Information Services (IIS) 下运行,而不是在 Apache 下运行.IIS 也支持 URL 重写,但配置是在 Web.config 文件中完成的,而不是在 .htaccess 文件中.

WordPress on Windows Azure Websites runs under Microsoft Internet Information Services (IIS), not Apache. IIS also supports URL rewriting but the configuration is done in a Web.config file, not in a .htaccess file.

首先,在WordPress设置中,将永久链接改为不带index.php"的自定义结构,如:

First, in WordPress settings, change the permalink to a custom structure without "index.php", such as:

/%year%/%monthnum%/%day%/%postname%/

还要确保在 WordPress 设置的常规设置部分中,WordPress 地址 (URL) 和站点地址 (URL) 是正确的.

Also make sure in WordPress Settings, General Settings section, the WordPress Address (URL) and Site Address (URL) are correct.

接下来,使用 FTP、WebMatrix 或其他工具,在您的 WordPress 站点的根目录中创建一个 Web.config 文件:

Next, using FTP, WebMatrix or other tool, create a Web.config file in your WordPress site's root directory:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Main Rule" 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>

有关分步教程,请参阅Azure 上的漂亮 WordPress 永久链接.有关其他信息,请参阅 将 WordPress 博客迁移到 Windows Azure – 第 4 部分:漂亮的永久链接和 URL 重写规则.

For a step-by-step tutorial refer to Pretty WordPress Permalinks on Azure. For additional information refer to Moving a WordPress Blog to Windows Azure – Part 4: Pretty Permalinks and URL Rewrite rules.

这篇关于如何使用 WordPress 配置 Windows Azure 以进行 URL 重写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆