{"id":13522798,"url":"https://github.com/christian-krieg/yourls-plugin-base-url-rewrite","last_synced_at":"2026-07-16T11:03:08.202Z","repository":{"id":217023626,"uuid":"616724706","full_name":"christian-krieg/yourls-plugin-base-url-rewrite","owner":"christian-krieg","description":"This YOURLS plugin enables to create short links with a domain different from the YOURLS host domain","archived":false,"fork":false,"pushed_at":"2023-03-27T11:48:43.000Z","size":216,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T19:42:49.295Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christian-krieg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-21T00:27:16.000Z","updated_at":"2024-03-07T21:34:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0ba6cda-839c-4794-9fd7-d13748c73dc1","html_url":"https://github.com/christian-krieg/yourls-plugin-base-url-rewrite","commit_stats":null,"previous_names":["christian-krieg/yourls-plugin-base-url-rewrite"],"tags_count":4,"template":false,"template_full_name":"christian-krieg/yourls-plugin-sample","purl":"pkg:github/christian-krieg/yourls-plugin-base-url-rewrite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-krieg%2Fyourls-plugin-base-url-rewrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-krieg%2Fyourls-plugin-base-url-rewrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-krieg%2Fyourls-plugin-base-url-rewrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-krieg%2Fyourls-plugin-base-url-rewrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christian-krieg","download_url":"https://codeload.github.com/christian-krieg/yourls-plugin-base-url-rewrite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-krieg%2Fyourls-plugin-base-url-rewrite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261906870,"owners_count":23228358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:00:52.436Z","updated_at":"2026-07-16T11:03:08.172Z","avatar_url":"https://github.com/christian-krieg.png","language":"PHP","funding_links":[],"categories":["Plugins"],"sub_categories":["B"],"readme":"# BaseURL Rewrite [![Listed in Awesome YOURLS!](https://img.shields.io/badge/Awesome-YOURLS-C5A3BE)](https://github.com/YOURLS/awesome-yourls/)\n\n\u003c!-- Once you have committed code, get your plugin listed in Awesome YOURLS ! See https://github.com/YOURLS/awesome-yourls --\u003e\n\nTested with [YOURLS](https://yourls.org), version `1.9.2`.\n\n## Usage\n\n### General\n\nThis plugin rewrites short URLs by replacing the original base URL (as specified\nby ``YOURLS_SITE`` in `config.php`) with the base URL given in the plugin's\nconfiguration option as specified in the settings. If the base URL configuration\noption is empty, the original short URL stays untouched, and is returned.\n\nThis base URL configuration option can be different from the domain from which\nYOURLS is served (i.e., ``YOURLS_SITE``).  This plugin rewrites short URLs such\nthat they point to another (base) URL (e.g., ``https://acme.com/r``), which\ncan be helpful if you want to serve YOURLS from a different sub-domain (e.g.,\n``https://link.acme.com``), but generate short links for a sub-directory of the\ndomain for your main web presence (e.g., ``https://acme.com/r``).\n\nWhen using the REST API, this plugin provides an option to specify the name of a\nquery parameter, whose value holds a base URL to use for the generated short\nURL. For instance, if we name the query parameter ``base_url`` in the plugin\nconfiguration, we can request a short URL as follows:\n\n```\ncurl \"https://lnk.acme.com/yourls-api.php?signature=XXXXXXXXXX\u0026action=shorturl\u0026format=txt\u0026base_url=https://pink.pony\u0026url=https://this.is.my.veeeeery.long.url.com/with/a/very/deep/path.html?and=also\u0026some=query\u0026para=meters\"\n\nhttps://pink.pony/vUvNW\n```\n\nWe can freely choose the name of the query parameter, e.g., we can name it\n``foo_bar``, and YOURLS will return the same result:\n\n```\ncurl \"https://lnk.acme.com/yourls-api.php?signature=XXXXXXXXXX\u0026action=shorturl\u0026format=txt\u0026foo_bar=https://pink.pony\u0026url=https://this.is.my.veeeeery.long.url.com/with/a/very/deep/path.html?and=also\u0026some=query\u0026para=meters\"\n\nhttps://pink.pony/vUvNW\n```\n\n:bulb: **NOTE:** You must take care that the other end (e.g.,\n``https://acme.com/r``, ``https://pink.pony``) performs redirects back to the\nsite where YOURLS is served from (e.g. ``https://link.acme.com``).\n\n![The admin interface of the plugin](config.png)\n\n### URL precedence\n\nThe short link's base URL is chosen as follws:\n\n1. If the query parameter name is set in the plugin's configuration, and YOURLS\n   is accessed via the REST API with the query parameter assigned, the **query\n   parameter's value** is used as the generated shortlink's base URL.\n\n1. If the query parameter name is not set in the configuration, or no query\n   parameter is given in the query string when accessing YOURLS via the REST\n   API, the plugin's **default base URL** as configured in the plugin settings\n   is used as the generated shortlink's base URL.\n\n1. If no default base URL is set in the plugin configuration, the **value of\n   ``YOURLS_SITE``** is used as the generated shortlink's base URL.\n\n### Example\n\nLets assume the following:\n\n    YOURLS_SITE: \"https://link.acme.com\" (a constant defined in `config.php`)\n    ck_base_url_default: \"https://acme.com/r\" (a configuration option)\n    ck_base_url_query_parameter: \"base_url\" (a configuration option)\n\nThen, YOURLS will create the (example) short link (when accessed from the YOURLS\nadmin interface, or from the REST API without specifying the `base_url` query\nparameter):\n\n    https://acme.com/r/Ac3fG\n\ninstead of\n\n    https://link.acme.com/Ac3fG\n\nIf invoking YOURLS via its REST API while setting the ``base_url`` query\nparameter to ``https://foo.bar``, YOURLS returns the following shortlink (let's\nsay the full API call is specified like this:\n`https://lnk.acme.com/yourls-api.php?signature=XXXXXXXXXX\u0026action=shorturl\u0026format=txt\u0026base_url=https://foo.bar\u0026url=https://short.this/url/for/me`):\n\n    https://foo.bar/Ac3fG\n\n\nIt is assumed that the system behind ``https://acme.com/r`` performs (e.g.,\nwildcard) redirects from ``https://acme.com/r/(.*)`` to\n``https://link.acme.com/$1`` which are then further redirected by YOURLS to the\nrespective target URLs.\n\n\n## Installation\n\n### The easy way: git\n\n1. Change directory to `user/plugins` and clone the `git` repository of this plugin:\n\n      cd user/plugins\n      git clone https://github.com/christian-krieg/yourls-plugin-baseurl-rewrite\n\n1. Go to the Plugins administration page (e.g.\n   http://link.acme.com/admin/plugins.php`) and activate the plugin.\n\n1. Have fun!\n\n\n### The hard way: manual copy\n\n1. Change to directory ``user/plugins``:\n\n       cd user/plugins\n\n1. Download the latest stable release of the plugin from\n   https://github.com/christian-krieg/yourls-plugin-base-url-rewrite/releases,\n   e.g.:\n\n       wget -c https://github.com/christian-krieg/yourls-plugin-base-url-rewrite/archive/refs/tags/1.0.0.tar.gz\n\n1. Unzip the archive to ``user/plugins``, e.g.:\n\n       tar -xavvf 1.0.0.tar.gz\n\n1. Eventually upload the unzipped archive to your YOURLS instance (e.g., using\n   `ftp` or `sftp`)\n\n1. Create a symlink to the extracted folder, and name it\n`` yourls-plugin-baseurl-rewrite`` (basically we remove the version string),\n   e.g.:\n\n       ln -s yourls-plugin-baseurl-rewrite-1.0.0 yourls-plugin-baseurl-rewrite\n\n1. Go to the Plugins administration page (e.g.\n   http://link.acme.com/admin/plugins.php) and activate the plugin.\n\n1. Have fun!\n\n\n## Updating\n\n### The easy way: git\n\n1. Move into the plugin's directory, and pull the plugin's latest changes::\n\n    git pull\n\n2. Eventually, check out a specific version:\n\n    git checkout 1.1.0\n\n3. Configure the plugin in the administration page\n\n4. Have fun!\n\n\n### The hard way: manual download and copy\n\nFollow the [installation instructions for manual copy](#the-hard-way-manual-copy),\nand choose the most recent version.\n\n## License\n\nThis package is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristian-krieg%2Fyourls-plugin-base-url-rewrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristian-krieg%2Fyourls-plugin-base-url-rewrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristian-krieg%2Fyourls-plugin-base-url-rewrite/lists"}