2.1 KiB
2.1 KiB
Wiki Redirection Implementation
Overview
This document explains the implementation of the redirection from /wiki
routes to https://qualiwiki.cipherbliss.com/wiki
.
Implementation Details
The redirection is implemented using a Symfony Event Subscriber that intercepts all requests to paths starting with /wiki
before they reach the routing system.
Files Created
src/EventSubscriber/WikiRedirectSubscriber.php
: Event subscriber that handles the redirection
How It Works
- The
WikiRedirectSubscriber
subscribes to thekernel.request
event with a high priority (256) - When a request is received, the subscriber checks if the path starts with
/wiki
- If it does, it extracts the part after
/wiki
and constructs a redirect URL by appending this part tohttps://qualiwiki.cipherbliss.com/wiki
- It creates a 301 (permanent) redirect response and sets it on the event
- This short-circuits the request handling process, preventing the request from reaching the routing system
Example Redirects
/wiki
→https://qualiwiki.cipherbliss.com/wiki
/wiki/
→https://qualiwiki.cipherbliss.com/wiki
/wiki/page1
→https://qualiwiki.cipherbliss.com/wiki/page1
/wiki/page1/subpage
→https://qualiwiki.cipherbliss.com/wiki/page1/subpage
Technical Considerations
- The subscriber uses a high priority (256) to ensure it runs before the router processes the request
- It only processes main requests, not sub-requests
- It uses a 301 (permanent) redirect status code, which is appropriate for this type of redirection
- The implementation follows Symfony best practices for event subscribers
- The subscriber is automatically registered thanks to Symfony's auto-configuration feature
Testing
To test the redirection:
- Access any path starting with
/wiki
in the application - Verify that you are redirected to the corresponding path on
https://qualiwiki.cipherbliss.com/wiki
- Check that the redirect is a 301 (permanent) redirect
Maintenance
If the target URL needs to be changed in the future, update the REDIRECT_BASE_URL
constant in the WikiRedirectSubscriber
class.