Using vue-router in laravel, how to use html5 history
给我你的怀抱
给我你的怀抱 2017-05-16 16:46:44
0
2
732

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. . . .

给我你的怀抱
给我你的怀抱

reply all(2)
PHPzhong

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.

左手右手慢动作

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template