Yourls Swap Short Url
January 20, 2020 ยท View on GitHub
For tricky setups that require your short url to reside in a different location than your yourls installation
Example Cases
- I want to use http://shorturl.com as my short url but I want to install it at http://shorturl.com/yourls/
- I want to use http://sho.rt as my short url but I want to install it at http://longurl.sho.rt
Requirements
Installation
- place the /swap-short-url/ directory in yourls /user/plugins/ directory
- in config.php point YOURLS_SITE to the location of your yourls installation
- in config.php, at the very end, define the short url you wish to share with the public after "Personal settings..." Example:
define( 'YOURLS_SHORT_URL', 'http://shorturl.com' ); - Modify the .htaccess file at the location defined by YOURLS_SHORT_URL (see below)
- Activate the plugin by clicking Manage Plugins at the top of the admin interface and then clicking Activate next to the Swap Short URL plugin
htaccess
You need to direct traffic from your defined short url to your yourls installation. To do this, create (or modify) an .htaccess file in the directory you defined as your YOURLS_SHORT_URL with the following:
RewriteEngine On
RewriteBase /
# BEGIN YOURLS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z]+)/?$ http://shorturl.com/yourls/yourls-go.php?id=\$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+/?$ http://shorturl.com/yourls/yourls-infos.php?id=\$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+all/?$ http://shorturl.com/yourls/yourls-infos.php?id=\$1&all=1 [L]
# END YOURLS
Issues
.htaccess is tricky and everyon's setup will be slightly different so that part is on you. Otherwise, feel free to submit problems feature requests using the GitHub issue tracker
developed by @gerbz