Apache 无法识别 root 以外的目录
Apache not recognizing directories other than root
当尝试加载除 www.example.com 以外的任何内容时(例如,www.example.com/something),我从 apache 收到一个错误,指出 'the requested URL /something was not found on this server'.
对可能出现的问题有什么想法吗?
我是 运行 Digital Ocean 上的 laravel 应用程序 - LAMP/Ubuntu。
我的 apache2.conf 文件(删除注释):
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
RewriteEngine On
RewriteBase /var/www/html/scheduleify/app/public
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
Include /etc/phpmyadmin/apache.conf
编辑:还有启用站点的配置文件:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# 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 webmaster@localhost
DocumentRoot /var/www/html/scheduleify/public
# 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}/error.log
CustomLog ${APACHE_LOG_DIR}/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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Apache 是一个网络服务器——它的主要工作是向网络提供文件。如果它告诉您
处没有文件
http://example.com/foo/baz/bar
那么那里没有文件。一切正常
Laravel 是一个 PHP 应用程序,由 运行 文件 index.php
运行。如果
http://example.com/
http://example.com/index.php
正在通过 Laravel 正确渲染,这意味着 Laravel 正在工作。
为了让 URL 像
http://example.com/foo/baz/bar
通过 Laravel 呈现,Laravel 在 public
文件夹中包含一个 .htaccess
文件,该文件重定向 大多数(即使不是全部) URL秒到 index.php
。就是这个.htaccess
文件负责转
http://example.com/foo/baz/bar
进入
http://example.com/index.php/foo/baz/bar
在工作系统中,这发生在幕后。即从用户查看浏览器的角度来看,URL 仍然是 http://example.com/foo/baz/bar
如果第二种形式的 URL 正在您的服务器上呈现,那么几乎可以肯定是 .htaccess
问题。在您配置 webroot 的任何 <Directory
节点中,您都需要这样的东西
AllowOverride All
这告诉 Apache“嘿,让用户使用 .htaccess
文件重新配置您可以从 .htaccess
文件配置的所有内容。您可以找到更多信息 about AllowOverride on the apache docs site。
当尝试加载除 www.example.com 以外的任何内容时(例如,www.example.com/something),我从 apache 收到一个错误,指出 'the requested URL /something was not found on this server'.
对可能出现的问题有什么想法吗? 我是 运行 Digital Ocean 上的 laravel 应用程序 - LAMP/Ubuntu。
我的 apache2.conf 文件(删除注释):
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
RewriteEngine On
RewriteBase /var/www/html/scheduleify/app/public
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
Include /etc/phpmyadmin/apache.conf
编辑:还有启用站点的配置文件:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# 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 webmaster@localhost
DocumentRoot /var/www/html/scheduleify/public
# 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}/error.log
CustomLog ${APACHE_LOG_DIR}/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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Apache 是一个网络服务器——它的主要工作是向网络提供文件。如果它告诉您
处没有文件http://example.com/foo/baz/bar
那么那里没有文件。一切正常
Laravel 是一个 PHP 应用程序,由 运行 文件 index.php
运行。如果
http://example.com/
http://example.com/index.php
正在通过 Laravel 正确渲染,这意味着 Laravel 正在工作。
为了让 URL 像
http://example.com/foo/baz/bar
通过 Laravel 呈现,Laravel 在 public
文件夹中包含一个 .htaccess
文件,该文件重定向 大多数(即使不是全部) URL秒到 index.php
。就是这个.htaccess
文件负责转
http://example.com/foo/baz/bar
进入
http://example.com/index.php/foo/baz/bar
在工作系统中,这发生在幕后。即从用户查看浏览器的角度来看,URL 仍然是 http://example.com/foo/baz/bar
如果第二种形式的 URL 正在您的服务器上呈现,那么几乎可以肯定是 .htaccess
问题。在您配置 webroot 的任何 <Directory
节点中,您都需要这样的东西
AllowOverride All
这告诉 Apache“嘿,让用户使用 .htaccess
文件重新配置您可以从 .htaccess
文件配置的所有内容。您可以找到更多信息 about AllowOverride on the apache docs site。