search

Home  >  Q&A  >  body text

Using vue-router in laravel, how to use html5 history

How to use html5 history when using vue-router in laravel?
If new VueRouter({mode:'history',...}); is used, there will be no 127.0.0.1/#/ in the URL article, such # appears, and the route is not found. .
Waiting online. . . .

给我你的怀抱给我你的怀抱2807 days ago768

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-16 16:48:44

    Transfer HttpException to your View in the exception handling Handler for processing! The remaining requests can only be made in API mode

    Testing laravel 5.4

    Only routes are defined in web routing.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 16:48:44

    vue-router Enabling history mode requires the support of the backend server.

    If the server is Apache, the configuration is as follows:

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.html [L]
    </IfModule>

    If the server is Nginx, the configuration is as follows:

    location / {
      try_files $uri $uri/ /index.html;
    }

    See official website documentation for details.


    If the front-end is responsible for routing and the back-end only provides interfaces.
    Routes for interfaces are best defined in routes/api.php.

    reply
    0
  • Cancelreply