[英]/Localhost is redirecting to a inside htdocs folder instead the root
When I access my localhost (or 127.0.0.1) by browser I got redirect to a folder inside the root. 当我通过浏览器访问我的localhost(或127.0.0.1)时,我被重定向到根目录下的文件夹。 For example:
例如:
I started my xampp, go to the browser and put 127.0.0.1 instead being redirect to the htdocs root to see all my folders (projects), I'm redirect to an existing folder and can't access the anothers projects. 我启动了我的xampp,转到浏览器并将127.0.0.1改为重定向到htdocs root以查看我的所有文件夹(项目),我重定向到现有文件夹,无法访问其他项目。
Anybody knows how to fix this? 有谁知道如何解决这个问题? I searched a lot of question here but the all problems is to redirect to another folder instead of the root folder.
我在这里搜索了很多问题,但所有问题都是重定向到另一个文件夹而不是根文件夹。 I already checked my httpd.conf:
我已经检查了我的httpd.conf:
ServerRoot "C:/xampp/apache"
<Directory "C:/xampp/htdocs/">
After moving away my folder from the htdocs, I received the following message from the browser: 从htdocs移走我的文件夹后,我从浏览器收到以下消息:
Object not found. 找不到对象。 Error 404.
错误404。
Edit 编辑
I restarted my computer and not started the xampp. 我重新启动计算机而没有启动xampp。 I can access my localhost anyway.
无论如何我可以访问我的localhost。
Check your hosts file for some redirections 检查您的hosts文件是否有重定向
Then you can do the next (as i do for my local projects): 然后你可以做下一个(就像我为我的本地项目做的那样):
Create folder named localhost
inside htdocs and put all standart files there 在htdocs中创建名为
localhost
文件夹,并将所有标准文件放在那里
create folder mynewproject.local
and put some your .php there 创建文件夹
mynewproject.local
并将一些.php放在那里
Now go to xampp/apache/conf/extra and open httpd-vhosts.conf
and write 现在转到xampp / apache / conf / extra并打开
httpd-vhosts.conf
并编写
VirtualHost *:80> VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\localhost"
ServerName localhost
/VirtualHost> /虚拟主机>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:\xampp\htdocs\mynewproject.local"
ServerName mynewproject.local
ErrorLog "logs/mynewproject.local-error.log"
CustomLog "logs/mynewproject.local-access.log" combined
</VirtualHost>
Open your hosts file and add 打开您的主机文件并添加
127.0.0.1 mynewproject.local 127.0.0.1 mynewproject.local
Now you can acces your project via mynewproject.local
and localhost via localhost
现在,您可以通过
localhost
通过mynewproject.local
和localhost访问您的项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.