This is a simple URL shortener written in PHP. It does not require a database, as the original URL is encoded directly into the shortened URL itself. This project is ideal for lightweight applications where you want to quickly create and share shortened URLs without the overhead of database management.
- No Database Required: URLs are encoded within the URL itself, eliminating the need for database storage.
- Simple Encoding/Decoding: Uses Base64 encoding to shorten URLs.
- Automatic Redirection: Automatically redirects users to the original URL when they visit the shortened link.
- URL Encoding: The original URL is Base64 encoded and made URL-safe by replacing certain characters.
- URL Decoding: When a shortened URL is accessed, the script decodes the Base64 string to retrieve the original URL.
- Redirection: The user is automatically redirected to the original URL.
-
Clone the Repository:
git clone https://github.com/yourusername/php-url-shortener.git cd php-url-shortener -
Deploy the Application:
- Upload the
index.phpfile to your web server. - Ensure the server has PHP installed and configured.
- Upload the
-
Access the Application:
- Open your web browser and navigate to the location where you deployed the application.
- Enter a URL to shorten it.
-
Shorten a URL:
- Visit the web page where the application is hosted.
- Enter the URL you wish to shorten in the form provided.
- Submit the form to generate a shortened URL.
-
Use the Shortened URL:
- Copy the shortened URL provided by the application.
- Share it with others or use it in your web applications.
-
Automatic Redirection:
- When someone visits the shortened URL, they will be automatically redirected to the original URL.
-
Shorten a URL:
- Original URL:
https://www.example.com/some/long/path - Shortened URL:
http://yourdomain.com/abc123
- Original URL:
-
Access the Shortened URL:
- When a user visits
http://yourdomain.com/abc123, they will be redirected tohttps://www.example.com/some/long/path.
- When a user visits
- PHP 5.4 or higher
- A web server with PHP support (e.g., Apache, Nginx)
This project is open-source and available under the MIT License. Feel free to use, modify, and distribute it as you see fit.
Enjoy your lightweight and database-free URL shortening service!