dpq59734 2017-05-01 07:33
浏览 68
已采纳

自定义页面将非www的错误重定向到从microsoft azure开发的wordpress站点的www

I have added this code in web.config of my wordpress site:

<rule name="Redirect to WWW site">
  <match url=".*" />
      <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" />
      </conditions>
  <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>

This perfectly works for redirection like homepage, default wordpress url(login.php, wp-admin). Examples:

  1. If I go to link poudelmadhav.com it redirects to www.poudelmadhav.com
  2. If I go to link poudelmadhav.com/wp-login.php it redirects to www.poudelmadhav.com/wp-login.php

But this doesnot work in custom pages of wordpress that I have created after installing wordpress. For examples:

  1. If I want to go poudelmadhav.com/contact it redirects to www.poudelmadhav.com not www.poudelmadhav.com/contact
  2. If I want to go poudelmadhav.com/about-me it redirects to www.poudelmadhav.com not www.poudelmadhav.com/about-me

I have followed the instructions from here. How can I solve this please help me.

  • 写回答

1条回答 默认 最新

  • duanpenpan5796 2017-05-01 10:04
    关注

    I was able to reproduce your issue on my site. To fix this, you'll need to move the code you posted above before Rewrite to index.php rule in the web.config file as below. And don't forget to clear the web browser's cache when you test it.

    <?xml version="1.0" encoding="UTF-8" ?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
    
                    <rule name="Redirect to WWW site">
                        <match url=".*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" />
                        </conditions>
                        <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent" />
                    </rule>
    
                    <rule name="Rewrite to index.php" 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>
    
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog