V
V
Vadim Timoshenko2020-05-29 14:27:12
htaccess
Vadim Timoshenko, 2020-05-29 14:27:12

How to make a redirect from a .png file to .php with saving GET parameters?

There is this code in .htaccess:

# BEGIN WordPress
# Директивы (строки) между `BEGIN WordPress` и `END WordPress`
# созданы автоматически и подлежат изменению только через фильтры WordPress.
# Сделанные вручную изменения между этими маркерами будут перезаписаны.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


I need to redirect from /ticket.png?ticket=00001to /ticket.php?ticket=00001. I add to the code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^ticket.png$ /ticket.php [QSA,R]
</IfModule>

# BEGIN WordPress
# Директивы (строки) между `BEGIN WordPress` и `END WordPress`
# созданы автоматически и подлежат изменению только через фильтры WordPress.
# Сделанные вручную изменения между этими маркерами будут перезаписаны.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


As a result, I go to /ticket.png and nothing =\

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-05-29
@PbI6A_KuT

RewriteRule ^ticket\.png$ /ticket.php [R=301,L]
If you need not a 301 redirect, but just an internal redirect.
RewriteRule ^ticket\.png$ /ticket.php [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question