未找到 在此伺服器上未找到請求的 URL

未找到 在此伺服器上未找到請求的 URL

這是我的虛擬主機的樣子the-square.local.conf

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t>
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin admin@the_square.com
ServerAlias the-square.local
ServerName the-square.local
DocumentRoot /var/www/html/the_square/public

<Directory /var/www/html/the_square/public>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/the-square.local-error.log
CustomLog ${APACHE_LOG_DIR}/the-square.local-access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

我已經啟用了該網站sudo a2ensite the-square.local

而且我還添加了/etc/hosts127.0.0.6 the_square.local

我已經重新啟動了 apache 2 systemctl reload apache2

我也這麼做了sudo chmod -R 755,也777參與了這個計畫。

我有其他虛擬主機工作沒有問題,但這次我找不到問題。

謝謝你!

  • 編輯:我將項目名稱更改為thesquare,並且在所有配置中也進行了此更改,但仍然出現相同的錯誤...

答案1

_從理論角度來看,有關在網域中使用下劃線的可能性的說明有點含糊。但在現代實踐中肯定不鼓勵這樣做。帶有下劃線的網域很可能無法解析且不被現代系統所允許。主機名稱也是如此,DocumentRoot在某些情況下甚至是 Apache。

請參閱這篇文章例如:

(網域名稱)子網域中可以有底線“_”嗎?

這篇文章與 Apache 相關DocumentRoot

錯誤請求 您的瀏覽器發送了該伺服器無法理解的請求

還值得注意的是 TLD.local.localdomain可能並非所有 DNS 旋轉器都完全支援,在這種情況下,可能會使用TLD 。

相關內容