Search code examples
phpregex.htaccessmatchregular-language

I need a regular expression to my htaccess


I'm very new to regular expression and I need to do a redirecting on my .htacess for some urls

Some examples are:

/lentes-de-contato/9/lentes-de-contato-biofinity-coopervision
/lentes-de-contato/9/lentes-de-contato-biofinity-teste
/lentes-de-contato/9/lentes-de-contato-biofinity
/lentes-de-contato/9/biofinity

The regex needs to match the word biofinity but don't match the word coopervision. I tried several ways to build an expression that looks like this: "biofinity" AND !"coopervision" but nothing seems to work. Till now I just have:

/lentes-de-contato/([0-9]+)/(.*biofinity.*)

Could anyone help me?


Solution

  • Maybe, so. Rewrterule will be achieved with your condition

    RewriteCond %{REQUEST_URI} biofinity
    RewriteCond %{REQUEST_URI} !coopervision
    RewriteRule