在初學(xué)PHP中遇到兩個問題,The requested URL /test.php was not found on this server 和You don't have permission to access / on this server. 搜索了很多博客,下面這個博客可以解決問題:
WampServer自定義網(wǎng)站根目錄
D盤新建了Demo文件夾(設(shè)定的網(wǎng)站根目錄),新建文本test.php,拓展名改為.php
輸入以下內(nèi)容,如果成功,則輸出success。
<?php
echo "success";
?>
瀏覽器中輸入要訪問的地址:localhost/test.php,出現(xiàn)以下結(jié)果:
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(設(shè)定的網(wǎng)站根目錄)
重新啟動所有服務(wù),就能夠訪問了


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

搜索Menu.left,
1、wampmanager.ini下把www 目錄對應(yīng)的filename改為自定義目錄

2、wampmanager.tpl下把${w_wwwDirectory}對應(yīng)的filename改為自定義目錄

退出、重啟服務(wù)器,www目錄變成了Demo目錄,不過是亂碼

點(diǎn)開后就轉(zhuǎn)到了D盤的Demo文件夾

原文地址:https://blog.csdn.net/qq_27542641/article/details/77076254
在編寫PHP文件時把PHP文件放到上面那個目錄下,運(yùn)行時在瀏覽器搜索欄輸入:localhost/文件名.php