laravel - 带有 Laravel 和 Apache 的虚拟主机,无法将 ip 设置为网站名称
问题描述
我想将我的网站的 ip 设置为按字母顺序排列的名称(即http://54.183.131.205到http://www.rblog.com)。虽然我已经在 /etc/apache2/sites-available 中配置了我的 rblog.com.conf,启用它并重新加载了我的 apache 服务器,然后添加到我的 /etc/hosts 文件 54.183.131.205 www.rblog.com(之间的标签ip 和网站名称),在我的浏览器中输入 www.rblog.com 不会将我重定向到我的 index.php 文件。但是,请注意,当我在浏览器中输入 IP 地址时,它会将我带到我的 index.php 文件(我相信这意味着我的 rblog.com.conf 文件是正确的?)。
<VirtualHost *:80>
ServerAdmin webmaster@rblog.com
ServerName www.rblog.com
ServerAlias www.rblog.com
DocumentRoot /var/www/html/rblog/public
<Directory /var/www/html/rblog/public>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
<FilesMatch \.php$>
</FilesMatch>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
解决方案
<VirtualHost *:80>
ServerAdmin webmaster@rblog.com
ServerName rblog.com
ServerAlias www.rblog.com
DocumentRoot /var/www/html/rblog/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我们可以使用 a2ensite 工具来启用我们的每个站点,如下所示:
sudo a2ensite example.com.conf
sudo a2ensite test.com.conf
完成后,您需要重新启动 Apache 以使这些更改生效:
sudo service apache2 restart
/etc/hosts 文件
54.183.131.205 rblog.com
推荐阅读
- php - MySQL数据库的重复条目条件
- python - Django你如何同时在两个列表中循环使用范围
- asp.net - 在 asp:datagrid 中以欧洲格式显示日期
- c++ - C++ 错误消息“我未在此范围内声明”
- c# - C# 从和返回到 Unix 时间戳
- postgresql - postgresql:显示客户端(不是服务器)时区
- laravel - 使用 Laravel Jetstream/Fortify 重新验证用户
- r - 有条件地删除每列的值,但使用循环将每列保留为新数据框
- windows - 无法将应用程序固定到 Windows 10 任务栏
- html - Safari 上的图像被扭曲了