Yuri Drobkov
Yuri Drobkov

Reputation: 183

Redirect using .htaccess to remove a part of filename in Apache

I know there are plenty of questions how to replace part of URL with something else (or nothing) using .htaccess but I really suck both in regular expressions and in .htaccess.

How can I to convert URL like /v0/A8B9DEBF512F929144257AEE00262C16/$File/IMG_8819.jpg to /v0/A8B9DEBF512F929144257AEE00262C16/IMG_8819.jpg? (Without $File/, instead of A8B9DEBF512F929144257AEE00262C16 and IMG_8819.jpg there may be any combination of digits and letters).

Upvotes: 0

Views: 57

Answers (1)

anubhava
anubhava

Reputation: 784878

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^(v0/[^/]+)/\$File/(.*)$ /$1/$2 [L,NC,R=301]

Upvotes: 1

Related Questions