T
T
T3R3AND2020-08-16 23:43:36
htaccess
T3R3AND, 2020-08-16 23:43:36

Convert htaccess?

There is nginx :

# nginx configuration
location /files/ {
if (-e $request_filename){
rewrite ^/files/([0-9\.]+\/.+)$ /files/../download.php?file=$1 break;
}
rewrite ^/files/(.*)$ /files/index.html break;
}


How to convert to htaccess ?
I know that there is an if/else feature in Apache, but I'm a bit confused...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2020-08-17
@shambler81

RewriteEngine On
# включаем mod_rewrite

#Частный случай,  редирект стоит выше чем на индекс ( читается сверху вниз)
RewriteRule  /files/([0-9\.]+\/.+)$ /files/../download.php\?file=$1

#Условие если  это не файл index.php
RewriteCond %{REQUEST_FILENAME} !/files/../index.php$
#  и если это не файл  download.php
RewriteCond %{REQUEST_FILENAME} !/files/../download.php$
#То все мело кидаем на индекс
RewriteRule ^/files/($ /inde.php [L]

something like that, but you need to check.

D
dodo512, 2020-08-17
@dodo512

.htaccess file in /files/ folder

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^([0-9.]+/.+)$ ../download.php?file=$1 [L]

RewriteRule (.*) index.html [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question