web: www-Hosts leiten kanonisch per 301 auf die Apex-Domain
Ploi kann nur Pfad-Redirects, daher als App-Middleware (früh im globalen Stack): GET/HEAD auf www.<domain> → 301 auf die Apex-Domain mit Pfad und Query. Unsichere Methoden werden nicht umgeleitet (301 verwirft den Body) — die beantwortet die App dank Host-Normalisierung weiterhin selbst. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
e69ded4fed
commit
fcf83040db
3 changed files with 75 additions and 0 deletions
32
tests/Feature/Web/WwwRedirectTest.php
Normal file
32
tests/Feature/Web/WwwRedirectTest.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Kanonische Hosts (RedirectWwwToApex): www-Varianten leiten per 301 auf die
|
||||
* Apex-Domain, Pfad und Query bleiben erhalten. Unsichere Methoden werden
|
||||
* nicht umgeleitet (301 würde den Request-Body verwerfen).
|
||||
*/
|
||||
test('www hosts redirect permanently to the apex domain keeping path and query', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->get('https://www.presseecho.test/de/impressum?foo=bar')
|
||||
->assertStatus(301)
|
||||
->assertRedirect('https://presseecho.test/de/impressum?foo=bar');
|
||||
|
||||
$this->get('https://www.businessportal24.test/de')
|
||||
->assertStatus(301)
|
||||
->assertRedirect('https://businessportal24.test/de');
|
||||
});
|
||||
|
||||
test('apex hosts are not redirected', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->get('https://presseecho.test/de/impressum')->assertSuccessful();
|
||||
});
|
||||
|
||||
test('unsafe methods on www hosts are answered instead of redirected', function () {
|
||||
/** @var TestCase $this */
|
||||
// POST darf nicht 301en (Body ginge verloren) — die App beantwortet den
|
||||
// Request dank Host-Normalisierung auch auf dem www-Host selbst.
|
||||
$this->post('https://www.presseecho.test/de/kontakt')
|
||||
->assertStatus(302); // Validierungs-Redirect der Kontakt-Route, kein 301
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue