【问题标题】:How to redirect from non-www to www in joomla site whith ssl如何使用 ssl 在 joomla 网站中从非 www 重定向到 www
【发布时间】:2014-07-19 13:41:54
【问题描述】:

我有一个 joomla 2.5 和美德玛特 2 网店。

在 www.mysite.com 中一切正常! 我的站点仅在结帐区域从 http 重定向到 https,然后在站点的其他区域返回(使用插件 SSL 重定向)。

问题是,如果您在结帐时插入带有 http:/mysite.com 的站点,重定向到 https://mysite.com/checkout 并且浏览器阻止了该页面(错误:ssl_error_bad_cert_domain) 并说证书仅适用于 www.mysite.com !!

如何解决这个问题。如果我使用 .htaccess

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

我在 ssl 区域有问题,因为 RewriteRume 有 http://?

.htaccess 里面有

##
# @package      Joomla
# @copyright    Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
# @license      GNU General Public License version 2 or later; see LICENSE.txt
##

##
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
##

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

## Mod_rewrite in use.

RewriteEngine On

## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects

##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##

# RewriteBase /

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.

【问题讨论】:

    标签: .htaccess ssl joomla virtuemart url-redirection


    【解决方案1】:

    尝试在 .htaccess 中添加以下行:

    RewriteCond %{HTTPS_HOST} ^mysite\.com$ [NC]
    RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,L]
    

    【讨论】:

    • RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    【解决方案2】:

    如果浏览器抱怨,因为证书仅适用于 www.mysite.com 但您希望它与 mysite.com 一起使用,那么浏览器可能是正确的。你可以做的是:

    【讨论】:

    • 嗨!我不想使用 mysite.com,但只能使用 www。我只想在结帐区域而不是在所有站点上使用 ssl。
    • 你不能从mysite.com重写到mysite.com,只要你没有mysite.com的有效证书,因为你首先需要建立连接(因此需要一个有效的证书) 在可以发送重定向之前。
    • 嗨!我不希望 example.comexample.com。我只需要example.com!我只在成功结帐时使用 ssl。
    猜你喜欢
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-12
    • 2018-09-11
    相关资源
    最近更新 更多