我的问题可能很愚蠢,但老实说,我搜索了很多并获得了成功但并不完整.
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://localhost
或 https://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.
请告诉我如何通过域名而不是使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!