zangane/smart-redirector

A powerful and flexible PHP redirect handler with time, IP, and user-agent conditions.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/zangane/smart-redirector

dev-main 2025-05-24 07:41 UTC

This package is auto-updated.

Last update: 2025-12-24 08:49:15 UTC


README

SmartRedirector is a powerful and flexible redirection handler for PHP applications. It allows you to manage HTTP redirects based on time limits, IP rules, user-agent conditions, and more. Ideal for shortlinks, campaign tracking, or dynamic routing.

🔧 Features

  • Easy and dynamic redirect rules
  • HTTP status code control (301, 302, etc.)
  • Expiry date/time support
  • IP-based allow/block rules
  • User-Agent based redirection
  • JSON-based configuration for easy customization
  • Composer-ready structure

📦 Installation

composer require zangane/smart-redirector

🧠 Usage

require "vendor/autoload.php";

use Zangane\SmartRedirector\Redirector;

$redirector = new Redirector("redirect-rules.json");
$redirector->handle();

⚙️ Configuration (redirect-rules.json)

[
  {
    "path": "promo",
    "target": "https://example.com/promo",
    "status": 302,
    "expire_at": "2025-12-31 23:59:59",
    "ip_allow": ["1.2.3.4"],
    "user_agent_block": ["bot", "curl"]
  }
]

📁 Directory Structure

- src/
  - Redirector.php
- examples/
  - basic.php
- redirect-rules.json
- logs/
  - access.log
- LICENSE
- README.md

📜 License

MIT License — see the LICENSE file for details.

🧬 Clone This Project

git clone https://github.com/zangane/SmartRedirector.git