在 xampp 中使用带有 https 的域名而不是本地主机 [英] Using Domain name instead of localhost in with https in xampp

查看:37
本文介绍了在 xampp 中使用带有 https 的域名而不是本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题可能很愚蠢,但老实说,我搜索了很多并成功但没有完成.

My question may be stupid, But honestly I searched a lot and got success but not complete.

我在 Windows 8 中使用 xampp.

I use xampp with windows 8.

我的主机文件如下所示.

My host file looks as follows.

    127.0.0.1   localhost
    127.0.0.1   www.mysite.com

我的 httpd-vhosts.config 如下所示.

My httpd-vhosts.config looks as follows.

    NameVirtualHost 127.0.0.1
    <VirtualHost 127.0.0.1>
        DocumentRoot "C:/xampp/htdocs"
        ServerName localhost
    </VirtualHost>
    <VirtualHost 127.0.0.1>
        ServerName www.mysite.com
        ServerAlias mysite.com
        DocumentRoot "C:/xampp/htdocs/mysite"
    </VirtualHost>

这适用于 http.但是我启用了 ssl.

This works perfect for http. But I have enabled ssl.

当我输入 http://localhosthttps://localhost 时,两者都工作正常.

When I type http://localhost or https://localhost, Both work fine.

当我输入 http://mysite.com 时,它可以工作,

When I type http://mysite.com it works,

当我输入 https://mysite.com 时,它会被重定向为 https://mysite.com/xampp/ 并显示 xampp 的默认欢迎页面.

when I type https://mysite.com it is redirected as https://mysite.com/xampp/ and shows me default welcome page of xampp.

我尝试了以下内容.

1) 而不是使用 127.0.0.1,我尝试在 httpd-vhosts.conf 中使用 *:80 但结果是一样的.

1) instead of using 127.0.0.1, I tried using *:80 in httpd-vhosts.conf But result was same.

2) 而不是使用 127.0.0.1,我尝试在 httpd-vhosts.conf 中使用 *:443 但是在重新启动 apache 时无法再次启动.

2) instead of using 127.0.0.1, I tried using *:443 in httpd-vhosts.conf But at the time of restarting apache fails to start again.

请告诉我如何通过域名而不是 localhost 和 https 或 http 访问我的网站.

Please let me know how can I access my site through domain name instead of localhost with https or http.

推荐答案

我尝试了很多东西,但我想我错过了基本的编辑.

I tried many things, But I think I missed basic edit.

现在一切正常.

现在主机文件仍然与问题中提到的相同.我没有对其进行任何更改.

Now host file is still the same as mentioned in question. I did not make any changes to it.

我在 httpd-vhosts.config 中更改了端口,如下所示.

I changed port in httpd-vhosts.config as shows below.

NameVirtualHost *
    <VirtualHost *>
        DocumentRoot "C:/xampp/htdocs"
        ServerName localhost
    </VirtualHost>
    <VirtualHost *>
        ServerName www.mysite.com
        ServerAlias mysite.com
        DocumentRoot "C:/xampp/htdocs/mysite"
    </VirtualHost>

也是我错过的步骤,是在 httpd-vhosts.config 所在的文件夹中编辑 httpd-ssl.config 文件.

Also the step I missed, was editing httpd-ssl.config file in same folder that of httpd-vhosts.config.

我刚刚在 http-ssl.config 文件的最后一行之前添加了以下几行,即 </IfModule>

I just added following lines before last line of http-ssl.config file i.e. < /IfModule>

<VirtualHost _default_:443> 
    DocumentRoot "C:/xampp/htdocs/mysite" 
    ServerName www.mysite.com:443 
    ServerAlias mysite.com:443  
    SSLEngine on 
    SSLCertificateFile "conf/ssl.crt/server.crt" 
    SSLCertificateKeyFile "conf/ssl.key/server.key" 
</VirtualHost> 

感谢所有在这方面帮助我的朋友,如果没有您的链接,我将永远无法发现我需要再编辑一个文件.

Thank You all friends for helping me lot on this, Without your links I would never ever be able to find out that I need to edit one more file.

这篇关于在 xampp 中使用带有 https 的域名而不是本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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