D
D
doorway-team2020-05-19 17:37:46
htaccess
doorway-team, 2020-05-19 17:37:46

How to redirect all files of a certain folder except for one to another domain?

There is a conditional site site1.ru. It has a folder /img/, in this folder there are many different files. There is also another domain site2.ru

How to make it so that when accessing the site1.ru/img/img0001.jpg file, the request is redirected for all files in the folder to site2.ru/img/img0001.jpg

However, the rules should NOT apply to the site1 file. ru/img/logo.jpg but should apply to everyone! files of the site1.ru/img/ folder

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2020-05-30
@doorway-team

RewriteCond %{REQUEST_URI} !^/img/logo.jpg$
RewriteRule ^img/(.+) $http://site2.ru/$1? [R=301,L]

D
dodo512, 2020-05-19
@dodo512

RewriteCond $1 !=logo.jpg
RewriteRule ^img/(.*) http://site2.ru/$0 [R=301,L]

Or
RewriteRule ^img/(?!logo\.jpg$).* http://site2.ru/$0 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question