Skip to content
This repository was archived by the owner on Jan 10, 2021. It is now read-only.

Commit 9ce82e5

Browse files
author
Nathan Glasl
committed
[FIX] Mappings will now be 301 by default, since this makes more sense from an SEO perspective.
1 parent bb223d2 commit 9ce82e5

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection)
22

3-
_The current release is **2.2.25**_
3+
_The current release is **2.2.26**_
44

55
> A module for SilverStripe which will allow both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling.
66

code/dataobjects/LinkMapping.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class LinkMapping extends DataObject {
2525
);
2626

2727
private static $defaults = array(
28-
'ResponseCode' => 303
28+
'ResponseCode' => 301
2929
);
3030

3131
/**
@@ -46,16 +46,14 @@ class LinkMapping extends DataObject {
4646
'LinkSummary',
4747
'Priority',
4848
'RedirectTypeSummary',
49-
'RedirectPageTitle',
50-
'isLive'
49+
'RedirectPageTitle'
5150
);
5251

5352
private static $field_labels = array(
5453
'MappedLink' => 'Mapping',
5554
'LinkSummary' => 'Redirection',
5655
'RedirectTypeSummary' => 'Redirect Type',
57-
'RedirectPageTitle' => 'Redirect Page Title',
58-
'isLive' => 'Is Live?'
56+
'RedirectPageTitle' => 'Redirect Page Title'
5957
);
6058

6159
/**

code/extensions/MisdirectionFallbackExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public function updateFields($fields) {
7878
$selection[$code] = "{$code}: {$description}";
7979
}
8080
}
81+
if(!$this->owner->FallbackResponseCode) {
82+
$this->owner->FallbackResponseCode = 303;
83+
}
8184
$fields->addFieldToTab($tab, DropdownField::create(
8285
'FallbackResponseCode',
8386
'Response Code',

code/requestfilters/MisdirectionRequestFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response,
9393

9494
$responseCode = $map->ResponseCode;
9595
if($responseCode == 0) {
96-
$responseCode = 303;
96+
$responseCode = 301;
9797
}
9898
else if(($responseCode == 301) && $map->ForwardPOSTRequest) {
9999
$responseCode = 308;

tests/MisdirectionFunctionalTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testRequestFilter() {
6969
// Determine whether the enforce misdirection is functioning correctly.
7070

7171
$response = $this->get('wrong/page');
72-
$this->assertEquals($response->getStatusCode(), 303);
72+
$this->assertEquals($response->getStatusCode(), 301);
7373
$this->assertEquals($response->getHeader('Location'), '/correct/page');
7474

7575
// The CMS module needs to be present to test page behaviour.

0 commit comments

Comments
 (0)