X
X
ximik2021-10-29 16:11:37
PHP
ximik, 2021-10-29 16:11:37

How to make the site display url and pictures in Russian letters as picture.jpg?

Good afternoon!
Faced such a problem. There are a lot of pictures in the encoded form
%D0.jpg uploaded to the site.

When opened in a browser, they do not work. And when you try to open site.ru/%D0.jpg directly, it gives 404
How to make the site show such pictures.

Perhaps somewhere there is a detailed instruction for dummies / a solution in htaccess or in php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zettabyte, 2021-10-29
@Zettabyte

One example is not enough. It can be, for example, Russian letters after URL encoding.
In JavaScript, you need this function: https://developer.mozilla.org/ru/docs/Web/JavaScri...
In PHP, try:

  • urldecode - php.net/manual/en/function.urldecode.php
  • rawurldecode, but then you need to convert the result to UTF-8:utf8_decode(rawurldecode('site.ru/%D0.jpg'));
  • decodeURIComponent

Please note that the functions above can handle + (plus) and similar characters differently - check it yourself, I haven't worked with this for a long time and forgot.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question