XAMPP 設置域名


 

找到XAMPP安裝目錄,

F:\xampp\apache\conf\extra\httpd-vhosts.conf

添加一段配置

<VirtualHost *:端口>
    ServerAdmin webmaster@你的域名
    DocumentRoot "F:/xampp/htdocs/你的域名"
    ServerName 你的域名
    ServerAlias 你的域名
    ErrorLog "logs/你的域名-error.log"
    CustomLog "logs/你的域名-access.log" common
</VirtualHost>

注意:把網站放到 "F:/xampp/htdocs/你的域名"  下,之前放在"F:/xampp/htdocs/"下導到報錯“找不到對象!”,一直找不到原因。后來在百度看到了

https://zhidao.baidu.com/question/1048485850522142779.html

因素其實不多的:
1 D:\xampp\apache\conf 在這個文件夾下 httpd.conf 這個配置文件你要確定沒改過

其中的
ServerRoot "/xampp/apache"
還有監聽的80端口也是很重要的
如果你之前裝過SQL 服務器他會占用的你的80端口,可以修改文件里面的80改成 (例如81)

2 D:\xampp\apache\conf\extra 這里有個httpd.vhost文件也是一個重要的配置
<VirtualHost *:80>
 Options None
 DocumentRoot D:\xampp\htdocs 確定這個下面 有Index.php 才能找到
ServerName 你配置的虛擬域名
DirectoryIndex index.php index.html index.htm
 <Directory />
 AllowOverride All
 Order deny,allow
 Allow from all
 </Directory>
 <Directory "D:\xampp\htdocs\"> 確定這個下面 有Index.php 程序才能找到
Options FollowSymLinks
 AllowOverride All
 Order allow,deny
 Allow from all
 </Directory>
</VirtualHost>

3,沒有東西的話,試試在Localhost/你的控制器的名字
例如localhost/message

萬分不行,重裝,然后在htdocs文件夾下,先刪掉所有,再把你的東西放進去 
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM