├── LICENSE ├── README.md └── plugin.php /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YOURLS plugin : 404 if not found [![Listed in Awesome YOURLS!](https://img.shields.io/badge/Awesome-YOURLS-C5A3BE)](https://github.com/YOURLS/awesome-yourls/) 2 | 3 | By default and by design, when a requested short URL is not found, YOURLS redirects to the site root with a "302 temporary redirect" header. 4 | 5 | From the source: 6 | ```php 7 | yourls_redirect( YOURLS_SITE, 302 ); // no 404 to tell browser this might change, 8 | // and also to not pollute logs 9 | ``` 10 | 11 | This plugin outputs a default "`404 not found`" error page instead. 12 | 13 | ## Installation 14 | 15 | 1. In `/user/plugins`, create a new folder named `404-if-not-found`. 16 | 2. Drop these files in that directory. 17 | 3. Go to the Plugins administration page (eg. `http://sho.rt/admin/plugins.php`) and activate the plugin. 18 | 4. Have fun! 19 | 20 | ## License 21 | 22 | Do whatever the hell you want with this. 23 | -------------------------------------------------------------------------------- /plugin.php: -------------------------------------------------------------------------------- 1 | ' 28 | . '' 29 | . '404 Not Found' 30 | . '' 31 | . '

Not Found

' 32 | . '

The requested URL was not found on this server.

' 33 | . ''; 34 | die($notfound); 35 | } 36 | 37 | /** 38 | * if you want to display a custom 404 page instead, replace the above function with 39 | * the following : 40 | * 41 | * function ozh_404_if_not_found() { 42 | * yourls_status_header(404); 43 | * include_once('/full/path/to/your/404.html'); // full path to your error document 44 | * die(); 45 | * } 46 | * 47 | */ 48 | --------------------------------------------------------------------------------