Re: RewriteRule and priorities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





El lun, 17 jul 2023 a las 12:09, Konstantin Kolinko (<knst.kolinko@xxxxxxxxx>) escribió:
пн, 17 июл. 2023 г. в 05:24, Dave Wreski <dwreski@xxxxxxxxxxxxxxxxxxx.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

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux