Remove multiple directories from URL with unknown variables

Viewed 16

Trying to build a rewrite rule that would take a URL like this:

website.com/gallery/{WILDCARD}/gallery-name

and convert it to this:

website.com/gallery-name

I've tried this, but it doesn't work:

RewriteRule ^gallery/(.*)$\/(.*)$ /$1 [L,NC,R=302]
1 Answers

Of course, I found the answer after I posted my question:

RewriteRule ^gallery/([^/]+)/(.*)$ /$2 [L,NC,R=301]
Related