How to redirect only when exact url matches?

Simple add a ^ to beginning and a $ to the end

^ tells tells the regex to match the beginning of the url

$ tells tells the regex to match the end of the url

redirectMatch 301 ^/user$ http://clients.mydomain.com

So now your rule will only match /user and not /some/user or /user/name or /some/user/name


NOTE: If you want to match /user/ and /user then use ^/user/?$

? says to match the previous character/group zero to one times

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)