Skip to content

fix: correct redirect parsing to use destination URL instead of status code#59

Merged
jos-felipe merged 2 commits intomainfrom
jos-felipe/fix-redirect-parsing
Aug 24, 2025
Merged

fix: correct redirect parsing to use destination URL instead of status code#59
jos-felipe merged 2 commits intomainfrom
jos-felipe/fix-redirect-parsing

Conversation

@jos-felipe
Copy link
Copy Markdown
Owner

Summary

  • Fixed critical bug in redirect parsing where status code was used instead of destination URL
  • Enhanced configuration with comprehensive route definitions
  • Cleaned up obsolete test files and added project documentation

Changes Made

  • Config.cpp: Fixed parseLocationBlock() to use tokens[2] (destination URL) instead of tokens[1] (status code) for return directives
  • default.conf: Updated with comprehensive route configuration including static content, uploads, CGI, and redirect routes
  • Cleanup: Removed obsolete www/test.php and www/test.py files
  • Documentation: Added CLAUDE.md with project guidelines and build instructions

Bug Fix Details

Before: Location: 301 (incorrect - status code)
After: Location: / or Location: /index.html (correct - destination URL)

Test Results

✅ Both redirect routes tested with curl and Playwright:

  • /old-site// (301 redirect)
  • /legacy//index.html (301 redirect)

Test Plan

  • Build server successfully
  • Test redirect routes with curl (manual headers check)
  • Test redirect routes with Playwright (browser navigation)
  • Verify no redirect loops occur
  • Confirm proper HTTP 301 responses with correct Location headers

…s code

- Fixed Config.cpp to parse tokens[2] (destination URL) instead of tokens[1] (status code) for return directives
- Updated default.conf with comprehensive route configuration including redirects
- Removed obsolete test files (www/test.php, www/test.py)
- Added project documentation in CLAUDE.md

Redirect routes now work correctly:
- /old-site/ → / (301)
- /legacy/ → /index.html (301)
@jos-felipe jos-felipe merged commit 5b29632 into main Aug 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants