This YOURLS plugin adds new command to the YOURLS API: action=lookup-url-substr — searches all keywords in the database which resolve to long URLs containing specified substring. API call requires substr parameter. Literally LIKE %substr% SQL expression is used for entries filtering.
The plugin is useful when searching for URLs disregarding GET parameters: for example, search URL with any UTM tags combination.
Assume your database contains the following entries:
| keyword | url | comment |
|---|---|---|
| kw1 | https://subdomain.example.com/?abc=def | https, subdomain and parameter 1 |
| kw2 | subdomain.example.com | subdomain only |
| kw3 | https://subdomain.example.com?utm=123 | https, subdomain and parameter 2 |
| kw4 | http://example.com?utm=123 | http and parameter 2 |
| kw5 | http://example.com?abc=def&utm=123 | http, parameters 1 and 2 |
The following API calls will respond with the corresponding keywords field values:
action=lookup-url-substr&substr=subdomain.example.com=>["kw1","kw2","kw3"]action=lookup-url-substr&substr=example.com=>["kw1","kw2","kw3","kw4","kw5"]action=lookup-url-substr&substr=https://subdomain.example.com=>["kw1","kw3"]action=lookup-url-substr&substr=example.com?utm=123=>["kw3","kw4"]
- Copy plugin files to
$YOURLS_ABSPATH/user/plugins:cdinto directory defined via$YOURLS_ABSPATHconfiguration parameter of your YOURLS installation.cd user/plugins- Copy files:
- Either clone via git:
git clone https://github.com/bryzgaloff/yourls-api-lookup-keywords-by-url-substr.git. This will create a copy of this repository in the$YOURLS_ABSPATH/user/plugins/yourls-api-lookup-keywords-by-url-substrdirectory. - Or just manually create a directory
mkdir yourls-api-lookup-keywords-by-url-substrand copyplugin.phpfile into it.
- Either clone via git:
- Name of the plugin directory is arbitrary: all the info is stored in the comment block of
plugin.phpfile.
- Open plugins manager of your YOURLS:
https://$YOURLS_SITE/admin/plugins.php. - Activate plugin.