【问题标题】:Correct Vue after removing the public from the path从路径中删除公共后纠正 Vue
【发布时间】:2019-08-15 02:12:22
【问题描述】:

我从使用这条指令Laravel 5 – Remove Public from URL的路径中删除了“public”

但是现在 vue 脚本不起作用。 如果添加到路径公共脚本有效 (http://example.com/public/anket)

【问题讨论】:

  • 你为什么要从公共文件 url 中删除 public/?
  • 确保用户不要在站点地址后面输入“public”
  • 哦,抱歉,我以为您试图从公共目录(.js 或 .css 文件)中删除 /public

标签: php laravel-5 vue.js laravel-5.7


【解决方案1】:

修改后你需要像这样改变.htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

这样静态文件不会被忽略,Vue 组件会再次工作。

问候

【讨论】:

    猜你喜欢
    • 2016-07-29
    • 1970-01-01
    • 2018-09-20
    • 1970-01-01
    • 2019-03-13
    • 2015-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多