Lauren Eccles Lauren Eccles - 2 months ago 13x
Apache Configuration Question

Remove subfolder from URL if the next subfolder is a specified subfolder (.htaccess)

For example:

This is fine:

This is also fine:

But if the subfolder after ecommerce is seo, remove ecommerce:

This is not fine:
and should be redirected to


Assuming there is no .htaccess in ecommerce/, you can use this rule in site root .htaccess:

RewriteEngine On

RewriteRule ^ecommerce/(seo)(/.*)?$ /$1$2 [L,NC,R=302]