简体   繁体   English

如何将运行于azure上的www的带有ssl的wordpress网站重定向到非www

[英]how to redirect wordpress website with ssl to non-www from www running on azure

I am running a website, computergk.com hosted on windows azure and ssl (from windows azure) installed on it. 我正在运行一个网站,computergk.com托管在Windows azure和安装在其上的ssl(来自Windows azure)上。 I want to redirect the www version of the website to non-www. 我想将网站的www版本重定向到非www。 The existing web.config configuration is below: 现有的web.config配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="WordPress: http://computergk.com" 
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>

I have already forwarded www cname record of my domain to @. 我已经将域名的www cname记录转发到了@。 I am using Windows Azure SSL provided by Godaddy Class 2 Certification Authority. 我正在使用Godaddy Class 2证书颁发机构提供的Windows Azure SSL。 Please help me. 请帮我。

Thanks 谢谢

Open .htaccess and add this line 打开.htaccess并添加此行

RewriteEngine On
#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.computergk\.com [NC]
RewriteRule ^(.*)$ https://computergk.com/$1 [L,R=301]

# redirect http to https all domain
RewriteCond %{HTTPS} off
RewriteRule (.*) https://computergk.com%{REQUEST_URI} [R=301,L]

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

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