wordpress .htaccess www到nonwww(不起作用)

时间:2019-03-11 07:52:51

标签: wordpress .htaccess lamp

我有一个WordPress网站。永久链接已更改,因此创建了.htaccess文件

我还有另一个要求,即重定向www to nonwww

例如,我输入了https://www.why-deny.com.hk/

它仍然没有重定向到https://why-deny.com.hk/

在编辑.htaccess之后,www仍然无法直接指向非www。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.why\-deny.com.hk [NC]
RewriteCond https://www.why-deny.com.hk/ [NC]
RewriteRule ^(.*)$ http://why-deny.com.hk/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

已添加一条记录

添加了httpd.conf虚拟主机

<VirtualHost *:80>
    ServerName www.why-deny.com.hk
    Redirect permanent / https://why-deny.com.hk/
</VirtualHost>
<VirtualHost *:443>
    ServerName www.why-deny.com.hk
    Redirect permanent / https://why-deny.com.hk/
</VirtualHost>

2 个答案:

答案 0 :(得分:0)

RewriteEngine On

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.why\-deny.com.hk/ [NC]
RewriteRule ^(.*)$ https://why-deny.com.hk/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

答案 1 :(得分:0)

请在{ "error": { "code": "Conflict", "message": "System.InvalidOperationException: Runtime keys are stored on blob storage. This API doesn't support this configuration. Please change Environment variable AzureWebJobsSecretStorageType value to 'Files'. For more info, visit https://aka.ms/funcsecrets\r\n at Kudu.Core.Functions.FunctionManager.<GetKeyObjectFromFile>d__9`1.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Core\\Functions\\FunctionManager.cs:line 141\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Kudu.Core.Functions.FunctionManager.<GetFunctionSecretsAsync>d__12.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Core\\Functions\\FunctionManager.cs:line 220\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Kudu.Services.Functions.FunctionController.<GetSecrets>d__12.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Services\\Functions\\FunctionController.cs:line 141" } }

之前添加此内容
# BEGIN WordPress