G
G
GaserV2017-04-27 01:58:22
htaccess
GaserV, 2017-04-27 01:58:22

How to redirect to a directory?

Hi all! I use ember js. Uploaded the contents of dist (compiled files) to the host. So. If I open the site and go through the pages by clicking on the links, then everything is ok. But, if I am, for example, on the page www.ru/posts and refresh the page, I get a 404 error. I think you need to make sure that all requests go to the root of the site. How can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Romanov, 2017-04-27
@GaserV

Hello. You need to configure the web server config, which gives the static. Something like this:
Nginx

server {
  listen 80;
  root /home/app/dist/;
  index index.html;

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

Apache (.htaccess)
# html5 pushstate (history) support:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html [L]
</IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question