首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用以https开头的虚拟主机域名重定向

使用以https开头的虚拟主机域名重定向
EN

Stack Overflow用户
提问于 2015-05-14 13:00:50
回答 1查看 213关注 0票数 0

我试图将ME.com或www.ME网站重定向到https://NOTME网站。下面的代码可以工作,但当我键入https://ME点com时,它不会转到https://NOTME点com。我发现一个错误,那页不安全。代码如下:

代码语言:javascript
复制
<VirtualHost *:80>
ServerAdmin admin@ME dot com
ServerName ME dot com
    ServerAlias www dot ME dot com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www dot ME dot com
RewriteRule ^/(.*)$ http://NOTME dot com/$1 [L,R=301]
Redirect permanent / https://NOTME dot com/
DocumentRoot /var/www/xxx/xxx/
<Directory />
    Options FollowSymLinks
    AllowOverride all
</Directory>
<Directory /var/www/xxxx/xxxxx/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
    # MSIE 7 and newer should be able to use keepalive
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown        

还请注意,我设置了ME.com,删除了一个https证书,该证书设置在虚拟主机端口443。我还能把证书还给它吗?而且,ME.com和NOTME.com都在同一个服务器IP上。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-19 13:14:48

我就是这样解决这个问题的:

代码语言:javascript
复制
<VirtualHost *:443>
ServerAdmin x@ME.com
ServerName ME.com
ServerAlias www.ME.com
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www.ME.COM/$
RewriteRule ^/(.*)$ https://NOTME.COM/$1 [L,R=301]
Redirect permanent / https://NOTME.COM/

SSLEngine on
SSLCertificateFile /xxxxxxxxxxxx.crt
SSLCertificateKeyFile /xxxxxxxxxxxx.key
SSLCertificateChainFile /xxxxxxxxxxxxxx.crt

实际上,解决方案是永久地重定向到NOTME com。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30238079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档