Skip to content

JMcrafter26/shorty

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shorty 🔗

Banner

Latest Release License It's even ~USEFUL~

Shorty is a simple URL shortener for PHP, now with a simple interface.

Features

  • Fast and lightweight 🚀
  • Very easy to install 📦
  • Simple interface ✨
  • Highly customizable 🔧
  • RESTful API 💻
  • Whitelist support 🔒
  • Bot protection 🤖

An UI Demo is available here

Installation

1. Download and extract the files to your web directory.

2. Add a rewrite rule to your server:

For Apache, edit your .htaccess file with the following:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]

For Nginx, add the following to your server declaration:

server {
    location / {
        rewrite ^/(.*)$ /index.php?q=$1;
    }
}

3. Configure your Database credentials and other settings in the config.php file

4. To use the recaptcha, you need to get a site key and secret key from here and replace the xxxxxxxx in the recaptcha div <div class="g-recaptcha" data-sitekey="xxxxxxxxxx" data-callback="verifyCaptcha"></div> in shorten.html with your site key.

Generating short URLs

Simply head to your Shorty installation from your browser and navigate to /shorten.html for the simple interface.

API

To generate a short URL, simply pass in a url query parameter to your Shorty installation:

http://example.com/?url=http://www.google.com

This will return a shortened URL such as:

http://example.com/9xq

When a user opens the short URL they will be redirected to the long URL location.

By default, Shorty will generate an HTML response for all saved URLs. You can alter the response format by passing in a format query parameter.

http://example.com/?url=http://www.google.com&format=text

The possible formats are html, xml, text, and json.

Whitelist

By default anyone is allowed to enter a new URL for shortening. To restrict the saving of URLs to certain IP addresses, use the allow function:

$shorty->allow('192.168.0.10');

Requirements

  • PHP 5.1+
  • PDO extension
  • MySQL or SQLite database

Future Plans

I am working on a simple admin panel for shorty.

I will release it when it's done.

License

Shorty is licensed under the MIT license. Note: This is a fork of Mike Cao's Shorty

Stats

Stars Get these COOL BADGES Get these COOL BADGES

Made by a HUMAN 😵