我的问题可能是愚蠢的,但老实说,我搜索了很多,并得到了成功,但不完整。
我用xampp和windows8。
我的主机文件如下所示。
127.0.0.1 localhost
127.0.0.1 www.mysite.com
我的httpd-vhosts.config如下所示。
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。
当我键入http://localhost
或https://localhost
时,两者都可以正常工作。
当我输入http://mysite.com
时,它可以工作,
当我输入https://mysite.com
时,它被重定向为https://mysite.com/xampp/
,并显示xampp的默认欢迎页面。
我试着跟着事情走。
1)我没有使用127.0.0.1,而是尝试在httpd-vhosts.conf中使用 *:80,但结果相同。
2)我没有使用127.0.0.1,而是尝试在httpd-vhosts.conf中使用 *:443,但在重新启动时,Apache无法再次启动。
请让我知道如何通过域名而不是本地主机与https或http访问我的网站。
6条答案
按热度按时间t0ybt7op1#
我尝试了很多东西,但我想我错过了基本的编辑。
现在一切正常。
现在主机文件仍然与问题中提到的相同。我没有对它做任何修改。
我在httpd-vhosts.config中更改了端口,如下所示。
我也错过了一步,在httpd-vhosts. config的同一个文件夹中编辑httpd-ssl.config文件。
我只是在http-ssl.config文件的最后一行之前添加了以下行。< /IfModule>
谢谢你所有的朋友帮助我很多关于这一点,没有你的链接,我永远无法找到,我需要编辑一个文件。
zrfyljdw2#
让我一步一步地为其他人解释。
1.将您的自定义域名Map到HOSTS文件中的localhost。
通常在哪里可以找到
hosts
文件:/etc/hosts
。C:\Windows\System32\drivers\etc\hosts
打开主机文件并在下面添加一行。
2.告诉XAMPP您的自定义域名。
将以下内容添加到httpd-vhosts.conf
如果您的本地主机有端口,则添加为**
<VirtualHost *:80>
**重新启动Apache,现在您可以在浏览器中访问http://example.com。
3.如果要访问https://example.com
将下面的行添加到
httpd-vhosts.conf
gstyhher3#
我已经在谷歌上搜索了几个小时,试图找出为什么最新的XAMPP版本将1200 MS放在页面生成时间上...我想这可能是我的代码与一些相当复杂的类系统一起工作。这个线程指出了整个localhost <> 127.0.0.1
我在Windows 7上,我没有想到使用CMD来“ping localhost”
结果是“::1:“而不是127.0.0.1
在快速的windows/system32/drivers/etc/host文件编辑取消注解掉这一行之后
127.0.0.0 localhost
我的页面时间恢复正常。可能是其他人最近有这个问题,看到这个线程在谷歌排名第一,那么祝你好运!
jchrr9hc4#
我从多个自定义域开始。请参见下面的新代码:
注意:WordPress去掉了反斜杠,所以下面我用正斜杠代替了它们。我相信无论哪种方式,工作都是如此。
sc4hvdpw5#
我对apache不是很熟悉,但也许不指定一个端口默认值为:80,加上这个就能神奇地解决一切问题?
xqk2d5yq6#
我使用自己的域名(以.lc结尾)在localhost上开发Web应用程序。我将描述动态.lc域和开发环境的简单解决方案,它可以在不依赖互联网连接的情况下工作。
我也在我的博客上写过:http://www.michalseidler.com/development/localhost-development-enviromet-for-php/
对于这个例子,我尝试描述配置本地动态域 *.lc与Wamp服务器。我将我的项目存储在C:\wamp\www\projects\projectname\中,并使用动态Mapprojectname.lc。这意味着我可以访问domain [projectdirektoryname].lc的每个项目目录
步骤1 -配置本地WAMP服务器
首先,你需要将 *.lc域名的配置放在httpd.conf中:
你需要将.htaccess文件插入到项目目录中(在我的例子中是:C:\wamp\www\projects)此配置将 *.ls域Map到项目目录。例如:如果您在目录“myapp”中有源代码,您可以使用www.myapp.lc在浏览器中打开它。
在此更改后重新启动Wamp服务器
步骤2 -配置本地DNS服务器
因为我们不能在Windows主机文件中使用 *.lc,所以我们需要安装本地DNS服务器。我选择Acrylic DNS服务器是因为它的配置非常简单。
安装后找到AcrylicHosts文件(C:\Program Files(x86)\Acrylic DNS Proxy)并插入新行:
这只是我们需要的DNS配置,因此请重新启动Acrylic DNS服务。
步骤3 -网络适配器的配置
最后一步是安装新的假网络适配器并分配DNS服务器:1.单击“开始”菜单。2.搜索“cmd”。3.右键单击“cmd”并选择“以管理员身份运行”4.输入“hdwwiz.exe”5.在“欢迎使用添加硬件向导”中,单击“下一步”。6.选择“Install the hardware that I manually select from a list(Advanced)(安装我从列表中手动选择的硬件(高级))”,然后单击“Next(下一步)”。7.向下滚动并选择“网络适配器”,然后单击下一步。8.选择制造商“Microsoft”,然后选择网络适配器“Microsoft Loopback Adapter”,然后单击下一步。
在下一步中,您必须更改新创建的适配器的TCP/IP设置:1.使用管理员帐户登录到计算机。2.单击开始,指向控制面板,然后单击网络连接。3.右键单击环回连接,然后单击属性。4.在“此连接使用以下项目”框中,单击“Internet协议(TCP/IP)”,然后单击“属性”。出现“Internet协议(TCP/IP)属性”对话框。
现在关闭所有的对话框和它的完成!您可以尝试打开[您的项目名称].lc