Apache supports Vue router mode using HTML5History

I. Introduction

Front-end Vue router using the history mode, URL will look better than hash model that you want to play well, but also need to back-end configuration support, otherwise it will report a 404 error.

Note : 1 front-end code is omitted.

  2. Here the background using Apache service support.

Second, the back-end configuration deployment

1. Create a txt file, add the following configuration

 Referring to official documents

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

 Change the file name: .htaccess  (in front of a point)

 The paper put the same level and index.html

2. Set the mod_rewrite apache support

Find apache installation directory etc httpd.conf file / httpd / conf / under

Find "LoadModule rewrite_module modules / mod_rewrite.so", will remove the preceding "#" sign.

(If none is found, a new row must be on a separate line)

 3. Set the apache .htaccess Support

修改httpd.conf -> "AllowOverride None" 为 "AllowOverride All"

 4. Restart apache

Command: service httpd restart

 

Guess you like

Origin www.cnblogs.com/xhq1024/p/12626913.html