希望网站301重定向这一块支持同网站的重定向(很重要)

su8sanshi 2021-2-25 1361

      发现现在所有大型站点都301到www域名上,主机大师现在只支持两个站之间301重定向,也就是说20个站重定向要做40个站,服务器吃不消,而且根本也没办法管理,一般都是一个站都是绑定www和 @两个域名,希望控制面板支持一键实现@到 WWW或者 WWW到@重定向

最新回复 (5)
  • hws 2021-2-26
    引用 2

    您好,可以采用以下办法:
    一,在网站中正常绑定完所有的域名;
    二,在网站根目录下创建文件web.config
    添加内容如下(把域名换为您的域名):
    <?xml  version="1.0"  encoding="UTF-8"?>
    <configuration>
            <system.webServer>
                    <rewrite>
                            <rules>
                                    <rule  name="hws.com301"  stopProcessing="true">
                                            <match  url="(.*)"  />
                                            <conditions>
                                                    <add  input="{HTTP_HOST}"  pattern="^hws.com"  />
                                            </conditions>
                                            <action  type="Redirect"  url="http://www.hws.com/{R:0}"  />
                                    </rule>
                            </rules>
                    </rewrite>
            </system.webServer>
    </configuration>

  • su8sanshi 2021-2-26
    引用 3
    这个伪静态代码只有首页301了,内页不支持,这个很重要,希望能重视
  • su8sanshi 2021-2-26
    引用 4
    现在你的规则能用了,z-blog内置的伪静态打不开了,能一键支持内页的伪静态就好了
    <?xml    version="1.0"    encoding="UTF-8"?>
    <configuration>
                    <system.webServer>
                                    <rewrite>
                                                    <rules>
                                                                    <rule    name="hambb.cn301"    stopProcessing="true">
                                                                                    <match    url="(.*)"    />
                                                                                    <conditions>
                                                                                                    <add    input="{HTTP_HOST}"    pattern="^hambb.cn$"    />
                                                                                    </conditions>
                                                                                    <action    type="Redirect"    url="http://www.hambb.cn/{R:0}"    />
                                                                    </rule>
                                                    </rules>
                                    </rewrite>
                    </system.webServer>
    </configuration>

    <?xml    version="1.0"    encoding="UTF-8"?>
    <configuration>
                    <system.webServer>
                                    <rewrite>
                                                    <rules>
                                                                    <rule    name="hambb.cn301"    stopProcessing="true">
                                                                                    <match    url="(.*)"    />
    <conditions>
                                                                                                    <add    input="{HTTP_HOST}"    pattern="^c.com$"    />
                                                                                                    <add    input="{QUERY_STRING}"    pattern=".*"    />
    </conditions>
                                                                                    <action    type="Redirect"    url="http://www.hambb.cn/{R:0}"    />
                                                                    </rule>
                                                    </rules>
                                    </rewrite>
                    </system.webServer>
    </configuration>

    这一段是zblog自带的伪静态,用上面代码后内置的伪静态就不生效了
    <?xml  version="1.0"  encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
           <rule  name="/  Z-BlogPHP  Imported  Rule"  stopProcessing="true">
             <match  url="^.*?"  ignoreCase="false"  />
               <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/{R:0}"  />
           </rule>
           <rule  name="/  Z-BlogPHP  Imported  Rule  index.php"  stopProcessing="true">
             <match  url="^index.php/.*?"  ignoreCase="false"  />
               <conditions  logicalGrouping="MatchAll">
                 <add  input="{REQUEST_FILENAME}"  matchType="IsFile"  />
               </conditions>
             <action  type="Rewrite"  url="index.php/{R:0}"  />
           </rule>
                                                           
      </rules>
        </rewrite>
      </system.webServer>
    </configuration>
  • su8sanshi 2021-2-26
    引用 5
    能一键写入就好,我依次这样写内置伪静态直接打不开网页了
    <?xml        version="1.0"        encoding="UTF-8"?>
    <configuration>
                                    <system.webServer>
                                                                    <rewrite>
                                                                                                    <rules>
                                                                                                                                    <rule        name="hambb.cn301"        stopProcessing="true">
                                                                                                                                                                    <match        url="(.*)"        />
                                                                                                                                                                    <conditions>
                                                                                                                                                                                                    <add        input="{HTTP_HOST}"        pattern="^hambb.cn$"        />
                                                                                                                                                                    </conditions>
                                                                                                                                                                    <action        type="Redirect"        url="http://www.hambb.cn/{R:0}"        />
                                                                                                                                    </rule>
                                                                                                    </rules>
                                                                    </rewrite>
                                    </system.webServer>
    </configuration>

    <?xml        version="1.0"        encoding="UTF-8"?>
    <configuration>
                                    <system.webServer>
                                                                    <rewrite>
                                                                                                    <rules>
                                                                                                                                    <rule        name="hambb.cn301"        stopProcessing="true">
                                                                                                                                                                    <match        url="(.*)"        />
    <conditions>
                                                                                                                                                                                                    <add        input="{HTTP_HOST}"        pattern="^c.com$"        />
                                                                                                                                                                                                    <add        input="{QUERY_STRING}"        pattern=".*"        />
    </conditions>
                                                                                                                                                                    <action        type="Redirect"        url="http://www.hambb.cn/{R:0}"        />
                                                                                                                                    </rule>
                                                                                                    </rules>
                                                                    </rewrite>
                                    </system.webServer>
    </configuration>

    <?xml    version="1.0"    encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                  <rule    name="/    Z-BlogPHP    Imported    Rule"    stopProcessing="true">
                      <match    url="^.*?"    ignoreCase="false"    />
                          <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/{R:0}"    />
                  </rule>
                  <rule    name="/    Z-BlogPHP    Imported    Rule    index.php"    stopProcessing="true">
                      <match    url="^index.php/.*?"    ignoreCase="false"    />
                          <conditions    logicalGrouping="MatchAll">
                              <add    input="{REQUEST_FILENAME}"    matchType="IsFile"    />
                          </conditions>
                      <action    type="Rewrite"    url="index.php/{R:0}"    />
                  </rule>
                                                                                                                 
        </rules>
            </rewrite>
        </system.webServer>
    </configuration>
  • hws 2021-2-27
    引用 6

    您好,如果方便,请提供服务器登录信息,QQ3007358068

    根据你提供的规则文件,完整的文件如下:注意把网址改为你自己的网址

    <?xml  version="1.0"  encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
           <rule  name="/  Z-BlogPHP  Imported  Rule"  stopProcessing="true">
             <match  url="^.*?"  ignoreCase="false"  />
               <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/{R:0}"  />
           </rule>
           <rule  name="/  Z-BlogPHP  Imported  Rule  index.php"  stopProcessing="true">
             <match  url="^index.php/.*?"  ignoreCase="false"  />
               <conditions  logicalGrouping="MatchAll">
                 <add  input="{REQUEST_FILENAME}"  matchType="IsFile"  />
               </conditions>
             <action  type="Rewrite"  url="index.php/{R:0}"  />
           </rule>
           <rule  name="hws.com301"  stopProcessing="true">
                 <match  url="(.*)"  />
                 <conditions>
                    <add  input="{HTTP_HOST}"  pattern="^hws.com"  />
                 </conditions>
                 <action  type="Redirect"  url="http://www.hws.com/{R:0}"  />
            </rule>                                              
      </rules>
        </rewrite>
      </system.webServer>
    </configuration>


返回
发新帖