云服务器错误 - 文件不存在:/var/www/html/public

云服务器错误 - 文件不存在:/var/www/html/public

我最近将使用 Laravel 构建的 web 应用程序移至了 rackspace 云服务器。

由于我在 apache 配置中设置了根,因此主页解析得很好。

但是,当对任何路线发出请求时,服务器都会尝试查找具有该路线名称的实际文件。例如:

如果我要求

www.mywebapp.com/login

服务器错误日志显示

File Does Not Exist: /var/www/html/public/login

我的 Apache 配置的一部分

<Directory/>
Options FollowSymLinks
AllowOverride None
</Directory>

我的 .htaccess 位于公共文件夹中

# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html

# Note: ".htaccess" files are an overhead for each request. This logic should
# be placed in your Apache config whenever possible.
# http://httpd.apache.org/docs/2.2/howto/htaccess.html

# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
</IfModule>

# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

这是我的第一个 Web 应用程序,因此我对所有这些概念都很陌生,也没有接受过正式培训。请提出建设性的批评。非常感谢所有帮助。

编辑 1:更正 .htaccess 文件

答案1

您的问题是第一组重写,即:

RewriteCond %{REQUEST_URI} !public/

简单的解决方法是将所有内容移至“公共”文件夹而不是/var/www/html。另一个解决方法是删除该重写,除非您确实需要它。

相关内容