简体   繁体   English

/ Localhost重定向到内部htdocs文件夹而不是根目录

[英]/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): 然后你可以做下一个(就像我为我的本地项目做的那样):

  1. Create folder named localhost inside htdocs and put all standart files there 在htdocs中创建名为localhost文件夹,并将所有标准文件放在那里

  2. create folder mynewproject.local and put some your .php there 创建文件夹mynewproject.local并将一些.php放在那里

  3. 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>
  1. 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.

相关问题 Wordpress 重定向到 xampp 中的 htdocs 文件夹 - Wordpress redirecting to htdocs folder in xampp localhost htdocs文件夹锁定,可以吗? - localhost htdocs folder locking, is it possible? 主页无法在根文件夹(htdocs)上打开 - Home page not opens on root folder (htdocs) .htaccess用于重定向到本地主机项目根目录 - .htaccess for redirecting to localhost project root 将 codeIgniter 中的 Url 重定向到根文件夹 - Redirecting a Url in codeIgniter to a root folder XAMPP for Windows Vista:htdocs中的文件夹 - XAMPP for windows vista: folder inside htdocs 未捕获的 PDOException: SQLSTATE[HY000] [1045] C:\\xampp\\htdocs\\folder\\phpfile.php 中的用户 &#39;root&#39;@&#39;localhost&#39;(使用密码:NO)的访问被拒绝 - Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) in C:\xampp\htdocs\folder\phpfile.php PHP上载了Web根目录(htdocs)文件夹以外的目录? - PHP Upload dir other than web root (htdocs) folder? $ _SERVER [&#39;DOCUMENT_ROOT&#39;]只能在htdocs而不是子文件夹中工作 - $_SERVER['DOCUMENT_ROOT'] only working in htdocs not sub-folder SilverStripe子域上的“详细信息”页面正在重定向到根文件夹 - Detail page on a SilverStripe subdomain is redirecting to the root folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM