[英]XAMPP won't load index.php when using a domain name
So, when I use localhost/website/index.php to access index.php, it works just fine, yet when I use a domain name like website.com/website/index.php and try to access index.php from another page ,它不会将我重定向到那里,而是重新加载它已经在的页面。
然后,当我尝试通过搜索栏访问 index.php 时,它会抛出一个错误,提示This page isn't working.
有谁知道解决这个问题?
您需要为 Xampp 设置一个虚拟主机
这是一个应该添加到C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@website
DocumentRoot "C:/xampp/htdocs/website"
ServerName website.com
ErrorLog "logs/website-error.log"
CustomLog "logs/website-access.log" common
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@website
DocumentRoot "C:/xampp/htdocs/website"
ServerName website.com
SSLEngine On
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
<Directory "C:/xampp/htdocs/website">
php_flag log_errors on
php_value error_log "logs/website-error.log"
AllowOverride All
Order allow,deny
Allow from all
</Directory>
php_flag log_errors on
php_value error_log "logs/website-error.log"
CustomLog "logs/website-access.log" common
</VirtualHost>
您还需要配置本地主机文件以将 website.com 请求发送到本地 IP 地址。
您的主机文件在这里: c:\Windows\System32\Drivers\etc\hosts
添加条目: 127.0.0.1 website.com
这将允许您在本地计算机上访问该网站。
要访问本地网络上的网站,您可以如上所述更改所有计算机的主机文件,或将 DNS A 记录添加到您的网络交换机(如果它支持 DNS)
A website.com 192.168.1.51
(这是你的局域网IP地址)
如果您需要通过互联网访问 Xampp 上的网站,您需要在您的域名 DNS 控制面板中的公共 IP 地址中添加一条 A 记录。 您可以在此处找到您的公共 IP 地址: https://www.whatismyip.com/您还需要允许端口 80 和 443 上的流量通过路由器和防火墙。 If you do not have a static IP address from your internet service provider, you will need to update your domain name DNS A record each time your IP address changes - eg if you restart your router, and/or periodically)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.