Vamsi Mohan Jayanti Vamsi Mohan Jayanti - 8 months ago 42
Apache Configuration Question

How to write this URL rewrite rule to trucate unwanted content?

Iam using apache mod_rewrite to redirect some URL. I been able to some of the URLS but none of my rules are able to caprure this

and redirect it to


You can use this rule as your first rule in site root .htaccess or Apache config:

# this goes in httpd.conf
AllowEncodedSlashes On

RewriteEngine On

RewriteRule ^(/?mome/[^/]+)/.+$ /$1 [L,NC,R=301,NE]

This will match any URI starting with /mome and will truncate anything after 2nd path component.