当前位置: 首页 > 知识库问答 >
问题:

laravel此服务器上未找到请求的url

鞠嘉志
2023-03-14

我有一个Ubuntu 14.04内核。我正在这个服务器上安装我的Laravel应用程序。安装之后,我尝试将根目录设置为public。

sudo nano /etc/apache2/sites-available/000-default.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 webmaster@localhost
        DocumentRoot /var/www/html/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

我已将文档根目录更改为

DocumentRoot /var/www/html/public/

现在,当我试图通过123访问我的Laravel应用程序时。xxx。xxx。xxx/它显示主页,运行良好。它还获取所有GET变量。例:123。xxx。xxx。xxx?类型=WEF

但是当我转到其他链接时,例如123。xxx。xxx。xxx/login它给了我一个错误

Not Found

The requested URL /login/ was not found on this server.

Apache/2.4.7 (Ubuntu) Server at 104.236.234.85 Port 80

我有路线。php在本地主机上运行良好。但不在此服务器上。请帮帮我。

共有3个答案

黄查猛
2023-03-14

首先启用a2enmod rewrite然后重新启动apache

/etc/init.d/apache2 restart

点击这里回答这些问题

仇炜
2023-03-14

我通过执行以下操作解决了问题:检查是否有名为“重写”的模块。在以下位置加载您的apache:

cd /etc/apache2/mods-enabled/

如果不存在,请执行以下摘录:

sudo a2enmod rewrite

否则,更改Apache配置文件以整合“友好URL”的使用。

sudo nano /etc/apache2/apache2.conf

在编辑器中找到以下代码:

<Directory /var/www/> 
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</Directory> 

更改为:

<Directory /var/www/> 
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

之后,通过以下方式重新启动Apache服务器:

sudo /etc/init.d/apache2 restart
谷梁楚青
2023-03-14

这看起来像您必须通过将其添加到vhost来启用. htaccess

<Directory /var/www/html/public/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

如果这不起作用,请确保启用了mod_rewrite。

不要忘记在进行更改后重新启动apache!重启apache2服务

 类似资料:
  • 我已经通过Composer在这个目录中安装了Laravel5.2。 尽管我听说不推荐使用它,但我还是使用了文件夹上的来100%访问它。 我可以正确地看到laravel欢迎页面,但在尝试使用

  • 我得到了错误,当我改变. php文件。blade.php.之前,我改变了它得到了这个错误。 Hello控制器 /public/hello/index.blade.php 错误

  • 我用laravel建立了一个网站,并将我的域名转发到项目文件夹中。但是,当我进入网站时,它会显示错误:404未找到请求的URL/未在此服务器上找到 服务器php: . htaccess: 我ndex.php: 编辑#1 我做了一个public_html文件夹,并将laravel/Public的内容放在其中。更改路径以使用/.../laravel/bootstrap/app.php和/.../lar

  • 1.将我的文件上载到000webhost。我将公用文件夹中的所有文件放置到public_html,然后创建了一个名为laravel的文件夹,并在那里上载了所有其他文件。这是我的目录结构: 拉拉维尔 应用程序 引导 配置 .... 公共网页 index.html ...... 2.在我的索引中。php文件,我已经更改了一些内容 > 需要目录。'//laravel/引导/自动加载。php′; $app

  • 大家好,我需要一个解决方案laravel项目,当我尝试打开后端管理与 /control它给我一个错误"未找到-请求的资源 /control未在该服务器上找到。" 当我将名称"/Control"更改为"/Control5"或类似的东西时,它的工作正常,但问题是我使用 /control视图和其他!我是新来的laravel我不知道是什么问题?请帮我解决这个问题! 网状物php 仪表板控制器

  • 在名为qrcode的表中添加库存时,结果输出在此服务器上找不到请求的资源 /qrcodes。