T
T
Timur Kalimullin2016-08-29 20:22:00
1C-Bitrix
Timur Kalimullin, 2016-08-29 20:22:00

How to replace non-existent images using htaccess?

Good afternoon,
there is a demo version of the project on the local. The production version is actively filled in by the client on the Internet.
The database is periodically backed up, which leads to changes in elements and paths to their images. Naturally, I don’t send a folder with images to the repository, as a result I get a bunch of 403 errors, for example, on a page with a list of news.
The project works on 1C-Bitrix.
I think as an option in the local htaccess write something like:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule upload/(.*)$ http://myProdSite.ru/upload/$1 [R=302,L,NC]
  # другие правила bx

but to the best of my illiteracy with htaccess, I can't figure out what's wrong with the rule?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Makar Gerasimov, 2016-08-29
@MacFiss

First of all, with this line, you clearly say that your regular expression is not for the file.
Try

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/upload/(.*)$
RewriteRule ^(.*)$ http://myProdSite.ru/upload/$1 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question