• Resolved Erez Speiser

    (@erezspeiser)


    Hi

    I am trying to make an exception to a sitewide unload of a plugin.
    I want to enable it on certain specific pages.
    The URL in this example is: https://www.hike-israel.com/hikes/
    According to the help section I am using #/hikes/#.

    PROBLEM:
    It enables the plugin also on all the child pages of this URL. But I need it enabled on the specific URL and keep it disabled on the child pages.

    Could you please assist with the correct Regex syntax?

    Thanks!
    Erez

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gabe Livan

    (@gabelivan)

    @erezspeiser in this case you need to use a different RegEx. The one you have used is matching any URI containing /hikes/. So, you can use the following RegEx that will match exactly /hikes/ and any URI beginning with /hikes/? as you might have query strings appended to the URI such as /?utm_source=value_here.

    #(^/hikes/$)|(^/hikes/\?)#

    Check the following test URL to see how it would match for some of the possible URLs: https://regex101.com/r/5mnYfy/1/ – you will notice how only the parent pages are matched

    Happy testing and let me know if this would work fine on your end!

    PS: When I load the following page – https://www.hike-israel.com/hikes/hikes-in-the-galilee/ – it shows the shortcode [the-post-grid id=”16456″ title=””] suggesting that it didn’t take effect on that page, perhaps you unloaded the plugin behind it and you shouldn’t, just thought to let you know about it as it doesn’t look professional.

    Thread Starter Erez Speiser

    (@erezspeiser)

    Hello Gabe,

    Thanks for the prompt and spot-on support.
    Works very well!
    Also, the link to regex101 is very useful for future testing.

    A friendly remarks:
    I believe that many people that are not as professional as you find Regex very confusing.
    I think it would save you some support topics if you give more real examples with explanations in the documentation section.
    For example, in the #/contact/# example you are giving, it is hard to understand that it’s matching any URL with the sting.

    Anyway, that’s for a great plugin and for your support.

    Erez

    Plugin Author Gabe Livan

    (@gabelivan)

    @erezspeiser thanks for the suggestion and I’m glad the RegEx works fine for you! There were examples given on the documentation page (e.g. https://www.assetcleanup.com/docs/what-are-plugins-unload-rules/).

    However, it still seems difficult for people to use them based on the feedback I got in the past months. I’m planning to implement a RegEx generator which would make things much easier. The generator would have something like: match the URI that starts with [string], ends with [string] (or both), or contains one or more of the following strings [list of strings, separated by a comma here), etc. It might not be the easier way, but still easier than writing the RegEx from scratch.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘url regex’ is closed to new replies.