A
A
Alexander Buki2020-01-26 08:49:32
Apache HTTP Server
Alexander Buki, 2020-01-26 08:49:32

How to set up apache for SPA?

Good afternoon.
There is a Single Page App on VUE JS with routing on the client.
The Apache settings in the .htaccess file look like this:

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

All clicks on links within the site work if you click from the main page.
But if you go through a direct link ( mysite.ru/anoterpage)
not to the main page, it gives 404
How to configure apache to immediately get to the desired route?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2020-02-02
@OnYourLips

You called me as an Apache specialist, but I'm not like that.
I can only give a solution for nginx:

location / {
    index index.html;
    try_files $uri /index.html$is_args$args;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question