wiitohzjeh
wiitohzjeh

Reputation: 347

Apache <LocationMatch> order and regexes

I've trying this for a couple of days and maybe am I wrong in some way. I'm trying to change the header depending on the final url, but the first capture group is always the same, /folder, happens that Apache is just using the last rule as I seen on the Apache Documentation seems like is the normal behaviour.

This is the current scenario:

I got three urls:

/folder
/folder/something
/folder/private

index, follow must be applied to /folder (the root) and /folder/private but the other ones must be on noindex, nofollow

And these are the regex currently on the configuration:

<LocationMatch "^\/(folder)$">
    Header set X-Robots-Tag "index, follow"
</LocationMatch>

<LocationMatch "^\/(folder)\/private(.*)">
    Header set X-Robots-Tag "index, follow"
</LocationMatch>

<LocationMatch "^\/(folder)(.*)">
    Header set X-Robots-Tag "noindex, nofollow"
</LocationMatch>

Maybe I'm using a bad regex? Out of ideas...

Thanks!

Upvotes: 1

Views: 475

Answers (0)

Related Questions