【问题标题】:Deployment of laravel project on heroku, assets are not working在heroku上部署laravel项目,资产不起作用
【发布时间】:2019-05-04 18:34:06
【问题描述】:

我已将我的 laravel 应用程序部署到 heroku,但我的路线不起作用,因为我发现我需要在我的路线中添加 index.php 才能访问它们,现在他们正在访问但我的 assets css js jquery 不起作用.这是我在 heroku 上的第一次部署,感谢您的帮助。

.htaccess

<IfModule mod_rewrite.c>
  <IfModule mod_negotiation.c>
      Options -MultiViews
  </IfModule>

  RewriteEngine On AllowOverride All
  # Redirect Trailing Slashes If Not A Folder...
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$ /$1 [L,R=301]

  # Handle Front Controller...
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [L]

  # Handle Authorization Header
  RewriteCond %{HTTP:Authorization} .
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

【问题讨论】:

    标签: laravel heroku


    【解决方案1】:

    在部署到 heroku 时,您不需要将 index.php 添加到路由和其他文件(css/js 等)。检查您是否对公用文件夹中的 htaccess 文件进行了任何更改。

    【讨论】:

    • 正如我上面提到的,我在我的路线中添加了index.php,它们工作正常,但是当我添加index.php/public/css/app.css时,它显示我laravel页面Sorry, the page you are looking for could not be found.
    • 试试 index.php/css/app.css
    • 请确认您的Procfile是否为web: vendor/bin/heroku-php-apache2 public/
    • 是的,我的Procfile 完全一样。
    • 检查heroku上是否启用了mod_rewrite
    猜你喜欢
    • 2018-04-19
    • 2021-10-17
    • 1970-01-01
    • 2019-03-25
    • 1970-01-01
    • 2021-09-04
    • 2015-05-17
    • 2019-03-17
    • 1970-01-01
    相关资源
    最近更新 更多