1. If the router is deployed to a secondary directory, set the Base attribute of the router to the secondary directory name
Source code file path: project root directory/SRC /router/index.js
2. Change the default configuration of axios baseURL to the project directory name
axios.defaults.baseURL=process.env.NODE_ENV==='production'?'/My-Vue/':'';
Copy the code
3. Change the value of the assetsPublicPath property to the name of the secondary directory
Source code file path: project root directory /config/index.js
4. Build the project my-VUE
5. Find the Apache configuration file (httpd.conf)
Find (#LoadModule rewrite_module libexec/apache2/mod_rewrite.so) and remove (#)
Find the following code to modify or add code as:
<Directory "/Library/WebServer/Documents/My-Vue"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Both Please see # # http://httpd.apache.org/docs/2.4/mod/core.html#options for more information. # Options FollowSymLinks Multiviews MultiviewsMatch Any # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # Require all granted </Directory>Copy the code
6. Create the (.htaccess) file in the server project directory.
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /My-Vue/ RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} ! -f RewriteCond %{REQUEST_FILENAME} ! -d RewriteRule . index.html [L] </IfModule>Copy the code