: .htaccess rewrite wildcard folder paths from host My desired result is change a file to root / from a N number of paths. For example: www.host.com/a/b/c/e/f/g/images/1.jpg, where A~G is not always
My desired result is change a file to root / from a N number of paths.
For example: host.com/a/b/c/e/f/g/images/1.jpg, where A~G is not always given. Result: host.com/images/1.jpg.
This is what I have so far: host.com/a/images --> host.com/images using: RewriteRule ^a/images/$ images/ [L].
What I need is a wildcard in front of /images/ like this: RewriteRule ^*/images/$ images/ [L].
How can I do this correctly in .htaccess?
More posts by @Margaret670
1 Comments
Sorted by latest first Latest Oldest Best
This should do the trick: RewriteRule ^.+/images/$ images/ [L]
In regex, the .+ is a wildcard matching at least one character, so it will match
host.com/**a**/images and host.com/**a/b**/images but not host.com/images.
When working with regular expressions for pattern matching, I have always found this page helpful: regular-expressions.info/.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.