• Resolved nomadandinlove

    (@nomadandinlove)


    How do I exclude the following directory?

    mywebsite.com/exclude-directory/page1/
    mywebsite.com/exclude-directory/page2/
    mywebsite.com/exclude-directory/page3/

    Is this correct?

    /^\/exclude-directory.*/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Anonymous User 16850768

    (@anonymized-16850768)

    You’re correct, the regular expression /^\/exclude-directory.*/ will exclude the pages listed above. It will also exclude the first level page, such as yourwebsite.com/exclude-directory/.

    Thread Starter nomadandinlove

    (@nomadandinlove)

    Thank you. How do I change the expression so it does not exclude the first level page?

    In other words, I want to exclude the following:

    mywebsite.com/exclude-directory/page1/
    mywebsite.com/exclude-directory/page2/
    mywebsite.com/exclude-directory/page3/

    But not exclude “mywebsite.com/exclude-directory/” from being cached.

    Also, is there a guide that I can read to learn more about creating these expressions?

    Anonymous User 16850768

    (@anonymized-16850768)

    You’re welcome! That could be done with the regular expression /^\/exclude-directory\/.+/ instead (https://regex101.com/r/k19zFv/1).

    PHP uses PCRE syntax. There are many resources available online that you can learn more about how to create regular expressions. A great place to start would be the PHP docs (https://www.php.net/manual/en/reference.pcre.pattern.syntax.php). I’m always happy to help answer any questions about these.

    Thread Starter nomadandinlove

    (@nomadandinlove)

    Thank you so much. Will definitely checkout the resource.

    Anonymous User 16850768

    (@anonymized-16850768)

    You’re very welcome, @nomadandinlove. Happy to have been able to assist.

    If you haven’t already and are able, leaving a review is always appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Exclude Cache with Page Paths’ is closed to new replies.