Vamsi Mohan Jayanti Vamsi Mohan Jayanti - 1 year ago 101
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download