【问题标题】:Vue+laravel+apache not redirecting properlyVue+laravel+apache 没有正确重定向
【发布时间】:2020-02-05 02:01:21
【问题描述】:

我试图在没有 php artisan serve 的情况下运行 vue+laravel 项目,但是当我访问 localhost/project/public 时,我看到一个空白页面,其中仅包含以下内容:

<head>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css? 
    family=Roboto:100,300,400,500,700,900"><link rel="stylesheet" 
     href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
</head>
 <body></body>

尽管如此,当我访问 localhost/project/public/any 时,我看到了我的默认未找到 vue 页面,因此当我单击返回主页按钮时,我可以毫无问题地访问我的整个项目。访问 localhost/project/public 时,任何人都可以帮助正确重定向到 / 路由。

注意:它适用于 php artisan serve,我正在尝试这个,因为我想在 ec2 实例中运行我的项目,但即使使用虚拟主机从 .htacces 重定向到 /project/public 也面临同样的问题 这不是 .htacces 问题,我可以根据需要进行重定向,但是当重定向到 /public 我的 vue 文件时,它没有被加载,这是我的 app.js:

import Vue from 'vue';
import 'vuetify/dist/vuetify.min.css'
import Vuetify from 'vuetify'
import 'material-design-icons-iconfont/dist/material-design-icons.css'
import App from './App.vue';
import store from './store';
import router from './router';
Vue.use(Vuetify)

require('./bootstrap');
const opts = {}
import ApiService from './api/api.service';

ApiService.init();
window.Vue = require('vue');
const app = new Vue({
    router,
    store,
    vuetify: new Vuetify(opts),
    components: { App },
    render: h => h(App)
}).$mount('#app');

这是我的 welcom.blade.php:

<!DOCTYPE html>
  <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <!-- CSRF Token -->
      <meta name="csrf-token" content="{{ csrf_token() }}">
      <title>{{ config('app.name', 'Administrador') }}</title>
      <!-- Scripts -->
      <script src="{{ asset('js/app.js') }}" defer></script>
      <!-- Fonts -->
      <link rel="dns-prefetch" href="https://fonts.gstatic.com">
      <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600" rel="stylesheet" type="text/css">
      <!-- Styles -->
      <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    </head>
    <body>
      <div id="app">
        <index></index>
      </div>
    </body>
  </html>

【问题讨论】:

标签: laravel vue.js vue-router


【解决方案1】:

如果你没有运行php artisan serve 你在运行什么? Laravel 要求服务器运行 PHP 以提供welcome.blade.php 文件。

【讨论】:

  • 阿帕奇。解决了我的公共文件夹 LOL 中只有一个 index.html 和 index.php,当我删除 index.html 时,所有这些都像魅力一样运行。是的,通过正确的配置,您可以在没有 php artisan serve 的情况下运行
猜你喜欢
  • 2018-04-14
  • 2019-03-25
  • 1970-01-01
  • 2020-10-10
  • 2016-04-14
  • 2014-12-05
  • 2019-07-23
  • 2020-02-10
  • 2021-12-06
相关资源
最近更新 更多