Beginner Url Rewrite htaccess

后端 未结 3 1438
孤街浪徒
孤街浪徒 2021-01-16 10:21

I would simply like to rewrite all requests from:

http://example.com/products/product.cfm?id=product-name

to

http://example         


        
3条回答
  •  抹茶落季
    2021-01-16 10:55

    Something along these lines:

    RewriteCond %{query_string} &?id=([^&]+) [NC] 
    RewriteRule ^/products/product.cfm$ /products%1? [R,NC,L]
    
    # Fragile, this assumes that params will always be in order id= then sub=
    RewriteCond %{query_string} &?id=([^&]+)&sub=([^&]+) [NC] 
    RewriteRule ^/category.cfm?$ /%1/%2? [R,NC,L]
    

    The R flag in the RewriteRule forces a hard redirect (the visitor's location bar will change to the new URL). Remove this flag for an internal redirect.

提交回复
热议问题