The requested URL /test.php was not found on this server

在初学PHP中遇到两个问题,The requested URL /test.php was not found on this server 和You don't have permission to access / on this server.  搜索了很多博客,下面这个博客可以解决问题:

WampServer自定义网站根目录

D盘新建了Demo文件夹(设定的网站根目录),新建文本test.php,拓展名改为.php

输入以下内容,如果成功,则输出success。

 
  1. <?php

  2. echo "success";

  3. ?>

浏览器中输入要访问的地址:localhost/test.php,出现以下结果:

Not Found

The requested URL /test.php was not found on this server.


Apache/2.4.23 (Win64) PHP/5.6.25 Server at localhost Port 80

需要配置一下apache里面的配置文件:

httpd.conf   和  httpd.vhosts.conf

打开后,搜索DocumentRoot更改路径

${INSTALL_DIR}/www/  和  c:/wamp64/www/  改为d:/Demo(设定的网站根目录)

重新启动所有服务,就能够访问了

同时,要更改安装包下面的wampmanager.ini 和wampmanager.tpl配置。

搜索Menu.left,

1、wampmanager.ini下把www 目录对应的filename改为自定义目录

2、wampmanager.tpl下把${w_wwwDirectory}对应的filename改为自定义目录

退出、重启服务器,www目录变成了Demo目录,不过是乱码

点开后就转到了D盘的Demo文件夹

原文地址:https://blog.csdn.net/qq_27542641/article/details/77076254

在编写PHP文件时把PHP文件放到上面那个目录下,运行时在浏览器搜索栏输入:localhost/文件名.php

猜你喜欢

转载自blog.csdn.net/moshanghuakai_pang/article/details/81274739