osm-labo/WIKI_REDIRECT_DOCUMENTATION.md

48 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

# 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
1. The `WikiRedirectSubscriber` subscribes to the `kernel.request` event with a high priority (256)
2. When a request is received, the subscriber checks if the path starts with `/wiki`
3. If it does, it extracts the part after `/wiki` and constructs a redirect URL by appending this part to `https://qualiwiki.cipherbliss.com/wiki`
4. It creates a 301 (permanent) redirect response and sets it on the event
5. 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:
1. Access any path starting with `/wiki` in the application
2. Verify that you are redirected to the corresponding path on `https://qualiwiki.cipherbliss.com/wiki`
3. 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.