How does apache configure to return a file when resources cannot be found?

if you want to make a server-rendered page, you only need to provide data at the backend, and the frontend uses vue to make a single page (for simple pages, only use < script > < / script > to introduce vue.js, without frontend routing).
when directly entering the address to access, the front end displays the corresponding page according to the url and obtains the data filling through the ajax, but the access path does not exist in the back end. This is described in the HTML5 History mode on vue"s official website:

however, background configuration support is required for this mode to play well. Because our application is a single-page client application, if the background is not configured correctly, when the user accesses http://oursite.com/user/id directly in the browser, it will return 404, which is not good-looking.

so, you need to add a candidate resource that covers all situations on the server: if the URL does not match any static resources, you should return the same index.html page, which is the page on which your app depends.

and give the configuration of apache backend:

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

I don"t know how to use this code. My environment is phpStudy (wmap),. I tried to add this code in .htaccess to the project directory (invalid), to httpd.conf in the apache directory (apache cannot be started), and to find the custom page code ErrorDocument 404 / 404.html on the Internet.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

put a 404.html and .htaccess of the same level, or 404 error, checked for a long time I just can not use, hoping to point out where my ideas or practices are wrong.

Aug.21,2021
Menu