PageSourceSearch

https://yourls.org/assets/js/def60162.4bbdf8a8.js

js yourls.org collected 2026-10-02 02:38:28 UTC 6,479 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[8991],{2447(e,n,o){o.r(n),o.d(n,{assets:()=>a,contentTitle:()=>l,default:()=>h,frontMatter:()=>r,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"guide/advanced/public-shortening","title":"Public shortening","description":"Tips and must-do things if you run a public shortening interface.","source":"@site/docs/guide/advanced/public-shortening.md","sourceDirName":"guide/advanced","slug":"/guide/advanced/public-shortening","permalink":"/docs/guide/advanced/public-shortening","draft":false,"unlisted":false,"editUrl":"https://github.com/YOURLS/website/edit/main/docs/guide/advanced/public-shortening.md","tags":[],"version":"current","frontMatter":{},"sidebar":"docs","previous":{"title":"Proxy","permalink":"/docs/guide/advanced/proxy"},"next":{"title":"Custom protocols","permalink":"/docs/guide/advanced/custom-protocols"}}');var s=o(4848),t=o(8453);const r={},l="Public shortening",a={},c=[{value:"Public Interface",id:"public-interface",level:2},{value:"Public API",id:"public-api",level:2},{value:"Spam",id:"spam",level:2},{value:"Protocols",id:"protocols",level:2},{value:"Globally",id:"globally",level:3},{value:"Depending on the user and context",id:"depending-on-the-user-and-context",level:3},{value:"Performance",id:"performance",level:2}];function d(e){const n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",p:"p",pre:"pre",strong:"strong",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"public-shortening",children:"Public shortening"})}),"\n",(0,s.jsx)(n.p,{children:"Tips and must-do things if you run a public shortening interface."}),"\n",(0,s.jsx)(n.h2,{id:"public-interface",children:"Public Interface"}),"\n",(0,s.jsxs)(n.p,{children:["Want to run your own little ",(0,s.jsx)(n.em,{children:"bitly"}),"? You need what is called a ",(0,s.jsx)(n.strong,{children:"public interface"})," along with your ",(0,s.jsx)(n.strong,{children:"private"})," YOURLS install. Make sure you read ",(0,s.jsx)(n.a,{href:"/docs/guide/essentials/private-or-public",children:"Private Or Public"})," first."]}),"\n",(0,s.jsxs)(n.p,{children:["A sample public interface is provided, named ",(0,s.jsx)(n.code,{children:"sample-public-front-page.txt"}),". Rename it as a ",(0,s.jsx)(n.code,{children:".php"})," file and customize it to suit your needs."]}),"\n",(0,s.jsxs)(n.p,{children:["You will find examples and inspiration in the ",(0,s.jsx)(n.a,{href:"https://github.com/YOURLS/awesome#showcases",children:"Showcase section"})," of Awesome YOURLS."]}),"\n",(0,s.jsx)(n.h2,{id:"public-api",children:"Public API"}),"\n",(0,s.jsxs)(n.p,{children:["Similarly, you can run a public API with a private install. There is also a sample file provided, named ",(0,s.jsx)(n.code,{children:"sample-public-api.txt"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"spam",children:"Spam"}),"\n",(0,s.jsx)(n.p,{children:"If you run a public interface, you will have to deal with spam and if you're not prepared, your webhost will not like it and eventually shut your account down."}),"\n",(0,s.jsxs)(n.p,{children:["Read the page about ",(0,s.jsx)(n.a,{href:"/docs/guide/troubleshooting/abuse",children:"Abuse"}),". Install anti spam plugins from the ",(0,s.jsx)(n.a,{href:"https://github.com/YOURLS/awesome",children:"Plugin List"})," or even consider adding a ",(0,s.jsx)(n.a,{href:"https://blog.yourls.org/2015/05/integrating-the-new-google-recaptcha-with-yourls/",children:"Captcha"}),". Also, read this ",(0,s.jsx)(n.a,{href:"https://blog.yourls.org/2013/03/getting-spam-links-in-yourls-read-this/",children:"blog post"}),"."]}),"\n",(0,s.jsx)(n.h2,{id:"protocols",children:"Protocols"}),"\n",(0,s.jsxs)(n.p,{children:["Out of the box, YOURLS 1.6+ allows URLs with common protocols such as ",(0,s.jsx)(n.code,{children:"ftp://"}),", ",(0,s.jsx)(n.code,{children:"mailto:"}),", ",(0,s.jsx)(n.code,{children:"ssh://"})," or ",(0,s.jsx)(n.code,{children:"facetime://"}),". See ",(0,s.jsx)(n.a,{href:"/docs/guide/advanced/custom-protocols",children:"Custom Protocols"})," for more info."]}),"\n",(0,s.jsx)(n.p,{children:"This is neat if you trust users, this is most likely unwanted if anyone can shorten links. It is easy to define what protocols will be allowed:"}),"\n",(0,s.jsx)(n.h3,{id:"globally",children:"Globally"}),"\n",(0,s.jsxs)(n.p,{children:["To ",(0,s.jsx)(n.strong,{children:"globally"})," enforce a custom set of allowed protocols and blacklist all others, just add the following at the end of your ",(0,s.jsx)(n.code,{children:"config.php"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-php",children:"$yourls_allowedprotocols = array( 'http://', 'https://', 'facet
1ime://' );\n"})}),"\n",(0,s.jsx)(n.h3,{id:"depending-on-the-user-and-context",children:"Depending on the user and context"}),"\n",(0,s.jsxs)(n.p,{children:["To contextually enforce depending on the user (logged in or not), use a plugin such as ",(0,s.jsx)(n.a,{href:"https://github.com/YOURLS/custom-protocol",children:"Custom Protocols"})]}),"\n",(0,s.jsx)(n.h2,{id:"performance",children:"Performance"}),"\n",(0,s.jsx)(n.p,{children:"Often asked is the question about the kind of webhost and server you need to run your public interface. There is no short answer: it completely depends on traffic & usage you expect."}),"\n",(0,s.jsxs)(n.p,{children:["YOURLS itself isn't much of a resource eater. The CPU load is virtually null and a redirection costs nothing. There's only a small SQL cost: each redirection generates 2 ",(0,s.jsx)(n.code,{children:"read"})," queries and 2 ",(0,s.jsx)(n.code,{children:"write"})," queries. Use these numbers to estimate what your web hosting is capable of."]}),"\n",(0,s.jsxs)(n.p,{children:["If you need further tweaking, you can install cache plugins or disable the logging - see ",(0,s.jsx)(n.a,{href:"/docs/guide/essentials/configuration",children:"Configuration"}),"."]})]})}function h(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},8453(e,n,o){o.d(n,{R:()=>r,x:()=>l});var i=o(6540);const s={},t=i.createContext(s);function r(e){const n=i.useContext(t);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(t.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.