codeigniter4 / codeigniter4/CodeIgniter4

Bug: Inconsistent hostname/subdomain limitation in Routing

Open
#7,214 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
6k
Forks
2k
Avg merge
1d 11h
Merged PRs (30d)
73

Description

CodeIgniter version: 4.3.1

(1) `hostname` takes precedence over `subdomain`
if a route has both:
```php
$routes->get('/', 'Home::index');
$routes->get('/', 'Media::index', ['hostname' => 'media.example.com:8888', 'subdomain' => '*']);
```
`http://media.example.com:8888/ci431/public/` → `App\Controllers\Media::index`
`http://user.example.com:8888/ci431/public/` → `App\Controllers\Home::index`

(2) `subdomain` takes precedence over `hostname`
if two routes matches:
```php
$routes->get('/', 'Home::index');
$routes->get('/', 'Media::index', ['hostname' => 'media.example.com:8888']);
$routes->get('/', 'All::index', ['subdomain' => '*']);
```
`http://media.example.com:8888/ci431/public/` → `App\Controllers\All::index`
`http://user.example.com:8888/ci431/public/` → `App\Controllers\All::index`

Contributor guide

Open the contributing guide

Research direction

Start in the Routing hostname and subdomain matching entry points; the issue provides reproduction routes and requests for media.example.com:8888 and user.example.com:8888. Reproduce both cases with CodeIgniter 4.3.1, then inspect the matching precedence. Done means hostname and subdomain constraints produce consistent, documented route selection in both examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.