我正在尝试将我的wordpress网站从http重定向到https。我的wordpress网站在EC2实例上,我在此link for redirection
的链接后面我能够看到https正常工作,但是从http到https的默认重定向没有发生。就像我转到http://testwordpress.com一样,它应该被重定向到https://testwordpress.com
我遵循了大部分答案from this link,但似乎没有任何对我有用
# 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>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ https://testwordpress.com/$1 [R,L]
</IfModule>
# END WordPress
以下代码给出了503错误代码
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTPS_HOST} !^testwordpress.com$ [NC]
RewriteRule ^(.*)$ https://testwordpress.com/$1 [L,R=301]
答案 0 :(得分:0)
要使用read a
read b
c=`scale=2;echo $a / $b | bc`
echo "Answer is: " $c
强制使用HTTP,您需要使用的是:
.htaccess
将其放在RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
文件的顶部,并确保在测试之前清除缓存。
答案 1 :(得分:0)
您需要更新wordpress数据库。请先尝试更新wp_options
。
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl'); UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
答案 2 :(得分:0)
RewriteEngine On RewriteBase /
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
这是另一个诽谤
<VirtualHost *:80>
ServerName www.example.com
Redirect / https://www.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
# ... SSL configuration goes here
</VirtualHost>
答案 3 :(得分:0)
// Add following code in htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Redirect 301 / https://testwordpress.com
</IfModule>
确保您在后端输入了https:
WordPress Address (URL)
Site Address (URL)
OR
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Rewrite HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{testwordpress.com}/$1 [R,L]
</IfModule>