如何从"localhost"更改URL在使用wampserver的本地系统上进行其他操作? [英] How to change the URL from "localhost" to something else, on a local system using wampserver?
问题描述
在Windows计算机上,有一个系统在本地wampserver上运行,但是当应用程序在localhost上运行时,URL则相反.
On a Windows machine, there's a system running on the local wampserver, but while the application is running on localhost, the URL says otherwise.
根据目录结构,我希望URL像这样:
While I would expect the URL to be like this based on the directory structure:
http://localhost/pro/include/db_report.php
开发人员已成功做到这一点:
The developer has managed to do this:
http://ap-mispro/pro/include/db_report.php
因此,URL显示的是ap-mispro
,而不是ap-mispro
.
So instead of localhost
, the URL says ap-mispro
.
两个URL都可以正常工作.
And both URLs work fine.
第二个URL是如何创建的?我尝试签出wampmanager.ini
和wampmanager.tpl
,但也许我不知道要寻找什么?
How is the second URL made? I tried checking out the wampmanager.ini
and wampmanager.tpl
but maybe I didn't know what to look for?
推荐答案
WINDOWS + WAMP解决方案
第1步
转到C:\wamp\bin\apache\Apache2.2.17\conf\
打开httpd.conf
文件并将
#Include conf/extra/httpd-vhosts.conf
更改为
Include conf/extra/httpd-vhosts.conf
即取消注释该行,以便它可以包含虚拟主机文件.
WINDOWS + WAMP solution
Step 1
Go to C:\wamp\bin\apache\Apache2.2.17\conf\
open httpd.conf
file and change #Include conf/extra/httpd-vhosts.conf
to
Include conf/extra/httpd-vhosts.conf
i.e. uncomment the line so that it can includes the virtual hosts file.
第2步
转到C:\wamp\bin\apache\Apache2.2.17\conf\extra
并打开httpd-vhosts.conf
文件并添加以下代码
Step 2
Go to C:\wamp\bin\apache\Apache2.2.17\conf\extra
and open httpd-vhosts.conf
file and add the following code
<VirtualHost myWebsite.local>
DocumentRoot "C:/wamp/www/myWebsite/"
ServerName myWebsite.local
ServerAlias myWebsite.local
<Directory "C:/wamp/www/myWebsite/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
根据您的要求更改myWebsite.local
和C:/wamp/www/myWebsite/
.
第3步
在C:/Windows/System32/drivers/etc/
中打开hosts
文件,并添加以下行(请勿删除任何内容)
Step 3
Open hosts
file in C:/Windows/System32/drivers/etc/
and add the following line ( Don't delete anything )
127.0.0.1 myWebsite.local
根据您的姓名要求更改myWebsite.local
change myWebsite.local
as per your name requirements
第4步
重新启动服务器.就这样
Step 4
restart your server. That's it
与WAMP相同的步骤只是根据XAMPP更改了与WAMP中的路径相对应的路径
Same steps as that of WAMP just change the paths according to XAMPP which corresponds to path in WAMP
这篇关于如何从"localhost"更改URL在使用wampserver的本地系统上进行其他操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!