Http到httpsku重定向到heroku上的WordPress [英] Http to Https redirect for wordpress on heroku

查看:135
本文介绍了Http到httpsku重定向到heroku上的WordPress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将所有网页重定向到https,以便在heroku上托管我的wordpress应用。我使用的是WordPress的HTTPS插件,并且我已经成功地让所有WordPress的页面重定向到https,但我的自定义页面不重定向。该应用程序使用此模板进行设置。传统上,人们似乎通过编辑.htaccess文件来完成此操作(例如此处),但我似乎无法让它工作。我也尝试向HTTPS插件URL过滤器添加'/',但这也不起作用。我所有试图将PHP代码添加到实际页面的操作都是以无限的重定向结束。

解决方案

看起来像是让我是htaccess中的订单。现在一切正常,我的文件看起来像这样

 #BEGIN WordPress 
< IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond%{HTTP:X-Forwarded-Proto}!https
RewriteRule ^。* $ https://%{SERVER_NAME}%{REQUEST_URI} [R ,L]

RewriteEngine On
RewriteBase /
RewriteRule ^ index\.php $ - [L]
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule。 /index.php [L]

< / IfModule>
#END WordPress

将https规则放在第一位非常重要,最初完成。


I'm trying to redirect all webpages to https for my wordpress app which is hosted on heroku. I'm using the Wordpress HTTPS plugin, and I've succeeded in getting all the wordpress pages to redirect to https, but my custom pages do not redirect. The app is setup using this template. It seems like people traditionally do this by editing the .htaccess file (for example here), but I can't seem to get that to work. I also tried adding '/' to the HTTPS plugin URL filters, but this didn't work either. All my attempts to add php code to the actual page just ends up in an infinite redirect.

解决方案

Looks like the thing that was getting me was the order in htaccess. Everything works now and my file looks like this

# BEGIN WordPress
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
# END WordPress

It was important to put the https rule first, which I hadn't done originally.

这篇关于Http到httpsku重定向到heroku上的WordPress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆