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

Detailed Analysis of Event Bubbling Mechanism in JavaScript

What is bubbling? There are three stages in DOM e...

Reasons and solutions for MySQL sql_mode modification not taking effect

Table of contents Preface Scenario simulation Sum...

Some experience in building the React Native project framework

React Native is a cross-platform mobile applicati...

An example of elegant writing of judgment in JavaScript

Table of contents Preface 1. Monadic Judgment 1.1...

How to disable ads in the terminal welcome message in Ubuntu Server

If you are using the latest Ubuntu Server version...

Design Theory: Textual Expression and Usability

<br />In text design, we usually focus on th...

How to call a piece of HTML code together on multiple HTML pages

Method 1: Use script method: Create a common head...

JavaScript canvas to achieve meteor effects

This article shares the specific code for JavaScr...

Linux ssh server configuration code example

Use the following terminal command to install the...

Detailed explanation of primary keys and transactions in MySQL

Table of contents 1. Comments on MySQL primary ke...

View the dependent libraries of so or executable programs under linux

View the dependent libraries of so or executable ...

Several implementation methods of the tab bar (recommended)

Tabs: Category + Description Tag bar: Category =&...