Search code examples
apache.htaccesshttp-redirectstaticmod-alias

How to redirect static files with htaccess by remove of one url part


I have such a query:

/upsell/someextrapath/images/image1.png

This path does not exist. I want to create a rule with htacess, which removes %someextrapath% from the url, so url will be working.

PS: this %someextrapath% can vary from one page to another. This is the main problem.


Solution

  • Try :

    RedirectMatch ^/upsell/.+/([^/]+)/(.+)$ /upsell/$1/$2