mod rewrite - .htaccess redirect all subcategories if page is in /shop/ subcategory -


question:

how can use .htaccess 301 redirect subdirectories (and subdirectories of subdirectories) in subdirectory /shop/ root and keep parameters?

situation:

i have webshop following structure:

    http://www.domain.com/shop/category1/category2/category3/product1.html?utm=code&source=web     http://www.domain.com/shop/category1/product2     http://www.domain.com/shop/category1/category6/product3 

we're working on new shop different structure. i'd have 301 redirect root of domain, old url follows:

    http://www.domain.com/shop/category1/category2/category3/product1.html?utm=code&source=web 

this url redirect to:

    http://www.domain.com/product1?utm=code&source=web 

i need remove /shop/, other subcategories keep parameters.

try :

rewriteengine on rewritecond %{the_request} /shop/cat1/cat2/cat3/product\.html\?utm=([^\&]+)&source=([^&\s]+) [nc]  rewriterule ^ /product?utm=%1&source=%1 [nc,r,l] 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -