[英]Wordpress redirection issue , any http url redirects to https homepage
I m using IIS and I have a wordpress installation and SSL installed.我正在使用 IIS,并且安装了 wordpress 和 SSL。 Any url requests which include http (eg: http://example.com/fooBar ), redirects to https://example.com homepage.I expect http ://example.com/fooBar redirects to https ://example.com/fooBar.
任何URL请求,其中包括HTTP(如: http://example.com/fooBar ),重定向到https://example.com homepage.I期望HTTP://example.com/fooBar重定向到https://例子。 com/fooBar。 What am i missing?
我错过了什么? Also, I am open for hardcoded solutions.
另外,我对硬编码解决方案持开放态度。 Honestly i have 2 specific http urls to redirect to their https versions.
老实说,我有 2 个特定的 http url 可以重定向到它们的 https 版本。
You may add this on your functions.php你可以在你的functions.php中添加这个
add_action('template_redirect', 'redirect_core', 50);
add_action('init', 'redirect_core', 50);
add_action('wp_loaded', 'redirect_core', 50);
function redirect_core(){
if (!is_ssl()) {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301);
exit();
}
}
or use this plugin: HTTPS Redirection或使用此插件: HTTPS 重定向
To fix this you will need to edit the sites 'Base URL' to include 'https'.要解决此问题,您需要编辑站点的“基本 URL”以包含“https”。 This can be done by going to your admin panel>General Settings and updating the 'WordPress Address (URL)' and the 'Site Address (URL)'.
这可以通过转到您的管理面板>常规设置并更新“WordPress 地址(URL)”和“站点地址(URL)”来完成。 Make sure that your .htaccess has the correct permissions set for this to take effect.
确保您的 .htaccess 具有正确的权限设置以使其生效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.