← Back to Projects

Version Routing Deployment System

About

The Version Routing Deployment System is a flexible version-based routing solution that automatically redirects users to the active version of your application. This system enables zero-downtime deployments and supports A/B testing by allowing seamless switching between different application versions without interrupting user sessions.

Built with PHP and Apache, this deployment system provides a simple yet powerful way to manage multiple versions of your web application, making it ideal for production environments where reliability and smooth transitions are critical.

Use Case

This system is perfect for scenarios where you need:

  • Zero-Downtime Deployments - Switch between application versions without taking your site offline
  • A/B Testing - Test different versions of your application with different user groups
  • Quick Rollbacks - Instantly revert to a previous version if issues are detected
  • Staged Rollouts - Gradually deploy new versions to a subset of users before full release
  • Version Management - Maintain multiple versions simultaneously for testing and production
  • URL Preservation - Maintain clean URLs while routing to different version folders

Key Features

  • ✅ Automatic Routing - Automatically routes users to the active version based on configuration
  • ✅ Zero-Downtime Switching - Switch versions instantly without service interruption
  • ✅ Easy Version Management - Web-based interface for switching between versions
  • ✅ URL Preservation - Preserves original URLs and query parameters during routing
  • ✅ Apache & PHP Support - Works with Apache (.htaccess) and PHP routing
  • ✅ Version History Tracking - Tracks deployment dates and version metadata
  • ✅ Security Features - Password protection and IP whitelisting for version management
  • ✅ Git-Ready - Sensitive files excluded from version control
  • ✅ Flexible Configuration - Easy to configure and customize for your needs

Technologies Used

PHP Apache .htaccess JSON mod_rewrite

How It Works

The system operates through a simple but effective workflow:

  1. User Request - User accesses your application at the root URL
  2. Router Processing - The main router (`index.php`) reads `version.json` to determine the active version
  3. Path Resolution - Router constructs the path to the active version folder
  4. Request Handling - The system includes/executes files from the active version while preserving URLs and parameters

All routing happens transparently, so users always see clean URLs while the system manages version switching behind the scenes.

Directory Structure

The system follows a clean, organized structure:

  • index.php - Main router that redirects to active version
  • .htaccess - Apache rewrite rules for URL routing
  • version.json - Configuration file tracking active version (not in Git)
  • switch-version.php - Web interface for version management
  • config.php - Security configuration (password, IP whitelist)
  • versions/ - Folder containing all application versions (v1.0, v1.1, v2.0, etc.)

License

This project is licensed under the MIT License - free to use and modify for your projects.