Skip to content

uzairdeveloper223/ShortU

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ShortU - Minimalist URL Shortener

License: MIT PHP Version MySQL Live Demo GitHub Stars

A clean, modern URL shortener with IP logging capabilities, custom aliases, and detailed analytics. Built with PHP and MySQL.

๐ŸŒ Live Demo: https://short-u.free.nf

Screenshots

ShortU Homepage Clean, minimalist interface for URL shortening

Dashboard Manage and track all your shortened URLs

Analytics Detailed IP logging and visitor analytics

Features

  • Custom Aliases: Create memorable short links with custom aliases
  • IP Logging: Track visitor analytics including location, device, browser, and OS
  • User Accounts: Register and manage your shortened URLs
  • Clean UI: Minimalist, newspaper-inspired design
  • Fast Redirects: Optimized for minimal latency
  • Analytics Dashboard: View detailed statistics for your links
  • Emoji Support: Use emojis in custom aliases
  • Mobile Responsive: Works seamlessly on all devices

Requirements

  • PHP 7.4 or higher
  • MySQL 5.7+ or MariaDB 10.2+
  • Apache with mod_rewrite enabled
  • PDO PHP Extension

Installation

1. Clone the Repository

git clone https://github.com/uzairdeveloper223/ShortU.git
cd ShortU

2. Configure Database

Create a MySQL database and import the schema:

mysql -u your_username -p
CREATE DATABASE shortu CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
exit;

Import the database schema:

mysql -u your_username -p shortu < htdocs/db.sql

3. Configure Application

Copy the example configuration file:

cd htdocs
cp config.example.php config.php

Edit config.php and update with your settings:

define('DB_HOST', 'localhost');
define('DB_NAME', 'shortu');
define('DB_USER', 'your_db_user');
define('DB_PASS', 'your_db_password');
define('SITE_URL', 'https://yourdomain.com');

4. Set Permissions

Ensure proper permissions:

chmod 644 config.php
chmod 755 htdocs/

5. Configure Apache

Ensure .htaccess is enabled and mod_rewrite is active:

sudo a2enmod rewrite
sudo systemctl restart apache2

Your Apache virtual host should allow .htaccess overrides:

<Directory /var/www/html/shortu/htdocs>
    AllowOverride All
</Directory>

6. Access the Application

Navigate to your domain in a browser:

https://yourdomain.com

Usage

Creating Short Links

  1. Enter a URL in the input field
  2. (Optional) Add a custom alias
  3. (Optional) Enable IP Logger for analytics
  4. Click "Shorten Link"

Viewing Analytics

  1. Register an account or login
  2. Navigate to the Dashboard
  3. View click statistics and IP logs for your links

API Endpoints

Shorten URL

POST /api/shorten.php
Content-Type: application/json

{
  "url": "https://example.com",
  "alias": "custom-alias",
  "is_logger": true
}

Validate Alias

GET /api/validate-alias.php?alias=custom-alias

Configuration Options

Edit config.php to customize:

  • DEFAULT_CODE_LENGTH: Length of auto-generated short codes (default: 6)
  • MAX_CUSTOM_CODE_LENGTH: Maximum length for custom aliases (default: 50)
  • SESSION_LIFETIME: Session duration in seconds (default: 7 days)
  • HASH_COST: bcrypt cost factor for password hashing (default: 12)

Security

  • Passwords are hashed using bcrypt
  • CSRF protection on forms
  • Prepared statements prevent SQL injection
  • Input validation and sanitization
  • Session security with custom session names

Development

Error Reporting

For development, enable error reporting in config.php:

error_reporting(E_ALL);
ini_set('display_errors', 1);

Remember to disable this in production!

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Design inspired by minimalist newspaper layouts
  • Uses Tailwind CSS for styling
  • Fonts: Playfair Display, Source Serif 4, JetBrains Mono

Support

๐ŸŒ Live Demo: short-u.free.nf

If you encounter any issues or have questions, please open an issue on GitHub.

Author

Uzair Mughal

Repository

https://github.com/uzairdeveloper223/ShortU

Roadmap

  • QR code generation for short links
  • Link expiration dates
  • Password-protected links
  • API key authentication
  • Export analytics data
  • Custom domains support
  • Link preview before redirect

Made with โค๏ธ for the open source community