在xampp中使用域名而不是localhost和https [英] Using Domain name instead of localhost in with https in xampp

查看:348
本文介绍了在xampp中使用域名而不是localhost和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)我尝试在httpd-vhosts.conf中使用*:80,而不是使用127.0.0.1,但是结果是相同的.

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.

请让我知道如何通过域名而不是使用https或http的localhost访问我的网站.

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中使用域名而不是localhost和https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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