F
F
FomaX2017-10-11 19:59:24
Nginx
FomaX, 2017-10-11 19:59:24

How to make a redirect to index.php of all requests, except for graphic files and css?

I'm making a front controller, redirecting all requests to index.php. How to exclude graphic files and css from falling under this rule - rewrite ^.*$ /index.php;
Or how to do it correctly and correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Mukovoz, 2017-10-11
@FomaX

Like this for example)

location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|pdf|txt|webp)$ {
     access_log off;
     expires 8d;
}

Or so
The first rule allows you to handle static in a separate location. The second rule checks if there is such a file or not, if the file does not exist, it is processed through index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question