https://github.com/supratimrk/url_shortener
A modern and scalable URL shortener application built with PHP and MySQL. This web app lets you shorten long URLs into compact, custom short codes and retrieve the original links seamlessly. Perfect for both personal use and production-scale deployment!
https://github.com/supratimrk/url_shortener
backend backend-server live mysql php simple-backend url-shortener url-shortner
Last synced: about 2 months ago
JSON representation
A modern and scalable URL shortener application built with PHP and MySQL. This web app lets you shorten long URLs into compact, custom short codes and retrieve the original links seamlessly. Perfect for both personal use and production-scale deployment!
- Host: GitHub
- URL: https://github.com/supratimrk/url_shortener
- Owner: SupratimRK
- License: mit
- Created: 2024-05-16T20:45:12.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-11T07:23:46.000Z (about 1 year ago)
- Last Synced: 2025-06-03T14:48:47.505Z (about 1 year ago)
- Topics: backend, backend-server, live, mysql, php, simple-backend, url-shortener, url-shortner
- Language: PHP
- Homepage: https://xrl.rf.gd
- Size: 123 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# π URL Shortener
A **modern and scalable** URL shortener application built with **PHP** and **MySQL**. This web app lets you shorten long URLs into compact, custom short codes and retrieve the original links seamlessly. Perfect for both personal use and production-scale deployment!
---
## π Features
- βοΈ **Shorten Long URLs**
Convert lengthy URLs into concise, easy-to-share short codes.
- π¨ **Custom Short Codes**
Personalize your short codes for brand recognition.
- π **Seamless Redirection**
Automatically redirect users from short codes to original URLs.
- π **Duplicate Detection**
Checks if a URL has already been shortened.
---
## π Prerequisites
- π₯οΈ **PHP** (>= 7.0)
- ποΈ **MySQL** or **MariaDB**
- π **Web Server** (e.g., Apache)
- π¦ **Composer** (for dependency management)
---
## βοΈ Installation
### 1οΈβ£ Clone the Repository
```bash
git https://github.com/SupratimRK/url_shortener.git
cd url-shortener
```
### 2οΈβ£ Set Up the Database
1. **Create the database:**
```sql
CREATE DATABASE url_shortener;
```
2. **Create the table:**
```sql
USE url_shortener;
CREATE TABLE urls (
id INT AUTO_INCREMENT PRIMARY KEY,
original_url VARCHAR(255) NOT NULL,
short_code VARCHAR(10) NOT NULL UNIQUE
);
```
3. **(Optional) Insert sample data:**
```sql
INSERT INTO urls (original_url, short_code) VALUES
('https://www.example.com', 'exmpl'),
('https://www.anotherexample.com', 'anothr');
```
---
### 3οΈβ£ Configure the Application
1. **Create a `config.php` file in the root directory:**
```php
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
```
2. **Include `config.php` in `index.php`:**
```php
```
---
### 4οΈβ£ Set Up the Web Server
1. **Apache Configuration:**
```apache
ServerAdmin webmaster@localhost
DocumentRoot "path_to_your_project_directory"
ServerName url-shortener.local
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
```
2. **Update Hosts File:**
```plaintext
127.0.0.1 url-shortener.local
```
3. **Restart Apache:**
```bash
sudo service apache2 restart
```
---
### 5οΈβ£ Access the Application
π Open your browser and visit: **`http://url-shortener.local`**
---
## π Usage
1. **Shorten a URL:**
- Enter your URL in the input field.
- (Optional) Add a custom short code.
- Hit the "Shorten" button.
2. **Retrieve the Original URL:**
- Access the short code in your browser (e.g., `http://url-shortener.local?x=shortcode`).
- The app redirects to the original URL if the code exists.
---
## πΈ Screenshot of the App
Here is a screenshot of the URL shortener in action:


---
## π License
π This project is licensed under the **MIT License**. Check the [LICENSE](LICENSE) file for details.
---
## π€ Contributing
We welcome contributions! Whether it's bug fixes, feature enhancements, or new ideas, feel free to:
- π οΈ Submit a Pull Request
- π Open an Issue
Letβs make this project even better together!
---
## π§ Contact
For inquiries, feedback, or support, reach out to **[supratimrk@outlook.com](mailto:supratimrk@outlook.com)**.
---
π‘ **Demo the Application Now:**
- **π Production:** [N/A](N/A)
- **βοΈ Development:** [xrl.rf.gd](https://xrl.rf.gd)
**Visit and explore the app live:** [xrl.rf.gd](https://xrl.rf.gd/)
---
β **Donβt forget to give a star on GitHub if you like it!**
Let me know your thoughts, and feel free to fork the repo for your custom needs! π