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

Commit

Permalink
[FIX] Mappings will now be 301 by default, since this makes more sens…
Browse files Browse the repository at this point in the history
…e from an SEO perspective.
  • Loading branch information
Nathan Glasl committed May 3, 2018
1 parent bb223d2 commit 9ce82e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection)

_The current release is **2.2.25**_
_The current release is **2.2.26**_

> 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.
Expand Down
8 changes: 3 additions & 5 deletions code/dataobjects/LinkMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LinkMapping extends DataObject {
);

private static $defaults = array(
'ResponseCode' => 303
'ResponseCode' => 301
);

/**
Expand All @@ -46,16 +46,14 @@ class LinkMapping extends DataObject {
'LinkSummary',
'Priority',
'RedirectTypeSummary',
'RedirectPageTitle',
'isLive'
'RedirectPageTitle'
);

private static $field_labels = array(
'MappedLink' => 'Mapping',
'LinkSummary' => 'Redirection',
'RedirectTypeSummary' => 'Redirect Type',
'RedirectPageTitle' => 'Redirect Page Title',
'isLive' => 'Is Live?'
'RedirectPageTitle' => 'Redirect Page Title'
);

/**
Expand Down
3 changes: 3 additions & 0 deletions code/extensions/MisdirectionFallbackExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function updateFields($fields) {
$selection[$code] = "{$code}: {$description}";
}
}
if(!$this->owner->FallbackResponseCode) {
$this->owner->FallbackResponseCode = 303;
}
$fields->addFieldToTab($tab, DropdownField::create(
'FallbackResponseCode',
'Response Code',
Expand Down
2 changes: 1 addition & 1 deletion code/requestfilters/MisdirectionRequestFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response,

$responseCode = $map->ResponseCode;
if($responseCode == 0) {
$responseCode = 303;
$responseCode = 301;
}
else if(($responseCode == 301) && $map->ForwardPOSTRequest) {
$responseCode = 308;
Expand Down
2 changes: 1 addition & 1 deletion tests/MisdirectionFunctionalTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testRequestFilter() {
// Determine whether the enforce misdirection is functioning correctly.

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

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

0 comments on commit 9ce82e5

Please sign in to comment.