Multiple vuecli projects are packaged and deployed on the Apache server

After the default vue project is packaged into the dist folder, directly copy the contents of the dist folder (excluding the dist folder) to the xampp/htdocs folder, and then you can open the project through the server ip address. However, it needs to be deployed in the htdocs
folder For multiple projects, some configuration is required.
insert image description here
insert image description here

Step 1: Configure in vue.config.js
insert image description here

publicPath:'//'

The publicPath is followed by your folder name

Step 2: Set in index.js in router
insert image description here

base:'//'

After base is also your folder name

Step 3: Add a .htaccess file to the packaged project and
insert image description here
insert image description here
change the place marked in the red circle to your folder name

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

Step 4: Find the httpd.conf file
insert image description here

Find the line AllowOverride None, change it to AllowOverride All,
restart the server and run it

Guess you like

Origin blog.csdn.net/weixin_37818738/article/details/126862113