Two solutions for Vue package upload server refresh 404 problem

Two solutions for Vue package upload server refresh 404 problem

1: nginx server solution, modify the .conf configuration file

There are two solutions

1:

    location / {
		try_files $uri $uri/ @router;
		index index.html;
	}
	location @router {
		rewrite ^.*$ /index.html last;
	}

2:

    location / {
        error_page 404 /index.html;
        #try_file $uri $uri/ /index.html =404;
    }

2: Apache server solution

(Assuming it is placed in the csdn directory) is divided into the following steps

1. Configure routing: Use history mode and configure base

2. Change assetsPublicPath in the config/index.js file to the file path you put on the server. The root directory is '/'. If it is placed in a folder, for example: /csdn/'

3. Modify Apache's httpd.conf file to support .htaccess,

4. Add the .htaccess file to the corresponding folder project. (Note that Windows does not support the format without a file name, i.e. .***, so you need to create a new text document first, write the content, then upload it to the corresponding directory via FTP, and then rename it. You will not be able to see it after renaming it here, so you need to set FTP to view hidden files)

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

5. Restart the server

Summarize

This concludes this article about two solutions to the 404 problem of refreshing the vue package upload server. For more relevant vue package upload server 404 content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue implements attachment upload function
  • Spring+Vue integrates UEditor rich text to upload picture attachments
  • Vue+element+oss realizes front-end fragment upload and breakpoint resume
  • Based on vue-simple-uploader, encapsulate the global upload plug-in function of file segment upload, instant upload and breakpoint resume
  • Vue form post request combined with Servlet to realize file upload function
  • Vue uses vue-quill-editor rich text editor and uploads pictures to the server
  • Realize mobile image upload, compression, drag-and-drop sorting, and drag-and-drop deletion functions based on Vue2
  • Things to note when uploading pictures with vue+vant
  • Vue realizes uploading after cropping pictures
  • Implementation example of uploading multiple attachments in Vue

<<:  Explanation of the steps for Tomcat to support https access

>>:  Solution to MySQL failure to start

Recommend

Mini Program Recording Function Implementation

Preface In the process of developing a mini progr...

Detailed explanation of the installation and use of Vue-Router

Table of contents Install Basic configuration of ...

Solution to MySQL failure to start

Solution to MySQL failure to start MySQL cannot s...

Practical experience of implementing nginx to forward requests based on URL

Preface Because this is a distributed file system...

Eight ways to implement communication in Vue

Table of contents 1. Component Communication 1. P...

Introduction to the B-Tree Insertion Process

In the previous article https://www.jb51.net/arti...

A few steps to easily build a Windows SSH server

The SSH mentioned here is called Security Shell. ...

Implementation of Bootstrap web page layout grid

Table of contents 1. How the Bootstrap grid syste...

Example code for implementing complex table headers in html table

Use HTML to create complex tables. Complex tables...

Several situations that cause MySQL to perform a full table scan

Table of contents Case 1: Case 2: Case 3: To summ...

An article teaches you how to use js to achieve the barrage effect

Table of contents Create a new html file: Create ...

Understand all aspects of HTTP Headers with pictures and text

What are HTTP Headers HTTP is an abbreviation of ...