How stearz/php-redirect-server works
Project type and purpose
• This is a small PHP–based web application whose sole job is to answer incoming HTTP requests by issuing redirects of various types.
• It uses a MySQL database to store redirect rules.
File structure
• Top‐level files:
• index.php – the main request handler
• config.inc.php – database connection settings
• mod_*.inc.php – pluggable modules, each implementing a different redirect type (301, 302, frame, proxy)
• There are no separate “frontend” or “backend” directories—everything runs in a single PHP‐enabled webserver process.
• The only external dependency is MySQL (configurable via config.inc.php).
Extract key architecture insights from the README
• Incoming HTTP requests hit index.php
• index.php loads config.inc.php to connect to the database, then dispatches to one of four modules based on the “type” field in the redirects table
• The database table (“redirects”) holds: id, type, name, target, activation window
• mod_proxy.inc.php may act as an HTTP proxy rather than issuing a redirect
Main components and their interactions
a. Client (browser or bot)
b. Web Server + PHP engine (Apache/nginx with PHP-FPM)
• Serves index.php
• Loads configuration (DB credentials)
• Dynamically loads one of the modules
c. Module plugins
• mod_301.inc.php – sends HTTP 301 response
• mod_302.inc.php – sends HTTP 302 response
• mod_frame.inc.php – returns an HTML frame wrapper pointing to target
• mod_proxy.inc.php – fetches content from the target and streams it back
d. MySQL database
• Table “redirects” stores the routing rules
e. (Optional) Logs or monitoring – not present in code but can be added
Architectural patterns and design principles
• Modular plugin architecture: each redirect type is a separate module file
• Single‐entry controller: index.php acts as the front controller
• Data‐driven routing: redirect logic is driven by database records
• Separation of concerns: config is isolated in config.inc.php
• Clear labels for: Client, Web Server + PHP, config.inc.php, index.php, each mod_*.inc.php, MySQL Database