S
S
Svah2018-04-18 03:06:11
Nginx
Svah, 2018-04-18 03:06:11

How to make nginx analog of regular expression through htaccess?

Tell me how to properly set up a regular expression through .htaccess
Now it works in conjunction: ngnix + php 70 + php-fpm
There is an img.php script that is called according to a certain rule through the nginx config

location /i {
    try_files $uri $uri/ /img.php?_url=$uri&$query_string;
}

This script works if the site address takes the form domain.ru/iRANDOM (for example, domain.ru/i123.png, or domain.ru/i/123.png, etc.)
The task is to make an analogue of this, but only through httpd + .htaccess or another, simpler option

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2019-07-18
@shambler81

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/img.php?$
RewriteRule ^(.*)$ /img.php? [L]
</IfModule>

like so, it may still be necessary to replace [L] with [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question