El lun, 17 jul 2023 a las 12:09, Konstantin Kolinko (<knst.koli...@gmail.com>)
escribió:

> пн, 17 июл. 2023 г. в 05:24, Dave Wreski <dwre...@guardiandigital.com
> .invalid>:
> >
> > Hi,
> >
> > I have a rewriterule like:
> >
> > RewriteRule ^/blog/(.*) /resources/blog/$1 [L,R=301]
> >
> > but I also have several instances where there are exceptions. In other
> words, I have an article at /blog/ that I want to be redirected to some
> place other than /resources/blog. How can I do this?
> >
>
>

I would start by defining exceptions first like Konstantino says, but I
would also try to avoid greedy expressions like (.*) which match absolutely
everything and tend to complicate things in the long run.

You can also try to use negative lookahead expressions which are used to
define exceptions like the ones you seem to describe, example:
/blog/(?!whatever_you_want_to_exclude)(.+)  /resources/blog/$1 [L,R=301]
(not negative lookahead group is not captured therefore it generates no
variable value.

When dealing with regular expressions a site or somewhere where to test
them is ideal too, I fancy debuggex.com in PCRE mode for example.

-- 
Daniel Ferradal
HTTPD Project
#httpd help at Libera.Chat

Reply via email to