Home redirect access to image symfony 3 .htaccess
Reply: 1

redirect access to image symfony 3 .htaccess

Islem Boussetta
Islem Boussetta Published in 2017-11-09 21:07:22Z

I have a website for GIFs and I want when a user tries to access to a GIF he will be redirected to another route. For example, if he types in the URL bar https://example.com/gif/YqHiZ3Mp.gif he will be redirected to https://example.com/gif/embed/YqHiZ3Mp

I tried this in .htaccess but nothing happened

<IfModule !mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^gif/([a-zA-Z0-9]+)\.gif$ /gif/embed/$1 [L,NC] 

Also wich .htaccess I have to edit? under /web directory?

Islem Boussetta
Islem Boussetta Reply to 2017-11-10 18:10:10Z

I find this solution

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^gif/([a-z\d]+)\.(gif)$ /gif/embed/$1 [R=301,L,NC]

but when I try to call a GIF with HTML or javascript it will be redirected too. Is there any way to ignore this rule when the call comes from code?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299341 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO