How to redirect page to 404 in magento2?
I want to redirect sales/order/history page to 404 in magento2.
magento2 404-page
add a comment |
I want to redirect sales/order/history page to 404 in magento2.
magento2 404-page
Add the URL to index.php to get 404 not found
– PMPD
yesterday
Can it possible by url rewrite?
– Rutvee Sojitra
yesterday
You can redirect using .htaccess too.
– Vivek
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
add a comment |
I want to redirect sales/order/history page to 404 in magento2.
magento2 404-page
I want to redirect sales/order/history page to 404 in magento2.
magento2 404-page
magento2 404-page
edited yesterday
PMPD
979
979
asked yesterday
Rutvee SojitraRutvee Sojitra
1,4071121
1,4071121
Add the URL to index.php to get 404 not found
– PMPD
yesterday
Can it possible by url rewrite?
– Rutvee Sojitra
yesterday
You can redirect using .htaccess too.
– Vivek
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
add a comment |
Add the URL to index.php to get 404 not found
– PMPD
yesterday
Can it possible by url rewrite?
– Rutvee Sojitra
yesterday
You can redirect using .htaccess too.
– Vivek
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
Add the URL to index.php to get 404 not found
– PMPD
yesterday
Add the URL to index.php to get 404 not found
– PMPD
yesterday
Can it possible by url rewrite?
– Rutvee Sojitra
yesterday
Can it possible by url rewrite?
– Rutvee Sojitra
yesterday
You can redirect using .htaccess too.
– Vivek
yesterday
You can redirect using .htaccess too.
– Vivek
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
add a comment |
3 Answers
3
active
oldest
votes
You can do using plugin.
Create around method on execute()
over class MagentoSalesControllerOrderHistory
and redirect to 404 page.
Plugin Class
<?php
namespace StackexchangeTestPlugin;
class HistoryPlugin
{
/**
* @var MagentoFrameworkAppActionContext
*/
private $context;
private $response;
private $redirect;
/**
* @var MagentoFrameworkUrlInterface
*/
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkUrlInterface $url
)
{
$this->context = $context;
$this->response = $context->getResponse();
$this->redirect = $context->getRedirect();
$this->url = $url;
}
public function aroundExecute(
MagentoSalesControllerOrderHistory $object,
callable $proceed
){
$norouteUrl = $this->url->getUrl('noroute');
$this->getResponse()->setRedirect($norouteUrl);
return;
}
/**
* Retrieve response object
*
* @return MagentoFrameworkAppResponseInterface
*/
public function getResponse()
{
return $this->response;
}
}
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
it will not work ? why it require code if funcnality is already there ?
– Minesh Patel
yesterday
add a comment |
Create di.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginName" type="VendorModulePluginOrderHistory" />
</type>
</config>
Create the plugin file
<?php
namespace VendorModulePluginOrder;
class History
{
private $context;
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
) {
$this->resultRedirectFactory = $context->getResultRedirectFactory();
$this->resultFactory = $context->getResultFactory();
$this->url = $url;
}
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
$resultRedirect = $this->resultFactory->create(MagentoFrameworkControllerResultFactory::TYPE_REDIRECT);
$norouteUrl = $this->url->getUrl('noroute');
$result = $resultRedirect->setUrl($norouteUrl);
return $result;
}
}
add a comment |
Hope this will help you.
You need to add the following code in di.xml
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginOrderHistory"
type="VendorModulePluginOrderHistory"
sortOrder="10"
disabled="false"/>
</type>
Then you need to add the following code in VendorModulePluginOrderHistory
History.php
<?php
namespace VendorModulePluginOrder;
use MagentoFrameworkExceptionNotFoundException;
class History
{
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
// your custom code after the original execute function
if ($returnValue) {
throw new NotFoundException(__('Parameter is incorrect.'));
}
return $returnValue;
}
}
?>
Thanks
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257052%2fhow-to-redirect-page-to-404-in-magento2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do using plugin.
Create around method on execute()
over class MagentoSalesControllerOrderHistory
and redirect to 404 page.
Plugin Class
<?php
namespace StackexchangeTestPlugin;
class HistoryPlugin
{
/**
* @var MagentoFrameworkAppActionContext
*/
private $context;
private $response;
private $redirect;
/**
* @var MagentoFrameworkUrlInterface
*/
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkUrlInterface $url
)
{
$this->context = $context;
$this->response = $context->getResponse();
$this->redirect = $context->getRedirect();
$this->url = $url;
}
public function aroundExecute(
MagentoSalesControllerOrderHistory $object,
callable $proceed
){
$norouteUrl = $this->url->getUrl('noroute');
$this->getResponse()->setRedirect($norouteUrl);
return;
}
/**
* Retrieve response object
*
* @return MagentoFrameworkAppResponseInterface
*/
public function getResponse()
{
return $this->response;
}
}
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
it will not work ? why it require code if funcnality is already there ?
– Minesh Patel
yesterday
add a comment |
You can do using plugin.
Create around method on execute()
over class MagentoSalesControllerOrderHistory
and redirect to 404 page.
Plugin Class
<?php
namespace StackexchangeTestPlugin;
class HistoryPlugin
{
/**
* @var MagentoFrameworkAppActionContext
*/
private $context;
private $response;
private $redirect;
/**
* @var MagentoFrameworkUrlInterface
*/
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkUrlInterface $url
)
{
$this->context = $context;
$this->response = $context->getResponse();
$this->redirect = $context->getRedirect();
$this->url = $url;
}
public function aroundExecute(
MagentoSalesControllerOrderHistory $object,
callable $proceed
){
$norouteUrl = $this->url->getUrl('noroute');
$this->getResponse()->setRedirect($norouteUrl);
return;
}
/**
* Retrieve response object
*
* @return MagentoFrameworkAppResponseInterface
*/
public function getResponse()
{
return $this->response;
}
}
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
it will not work ? why it require code if funcnality is already there ?
– Minesh Patel
yesterday
add a comment |
You can do using plugin.
Create around method on execute()
over class MagentoSalesControllerOrderHistory
and redirect to 404 page.
Plugin Class
<?php
namespace StackexchangeTestPlugin;
class HistoryPlugin
{
/**
* @var MagentoFrameworkAppActionContext
*/
private $context;
private $response;
private $redirect;
/**
* @var MagentoFrameworkUrlInterface
*/
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkUrlInterface $url
)
{
$this->context = $context;
$this->response = $context->getResponse();
$this->redirect = $context->getRedirect();
$this->url = $url;
}
public function aroundExecute(
MagentoSalesControllerOrderHistory $object,
callable $proceed
){
$norouteUrl = $this->url->getUrl('noroute');
$this->getResponse()->setRedirect($norouteUrl);
return;
}
/**
* Retrieve response object
*
* @return MagentoFrameworkAppResponseInterface
*/
public function getResponse()
{
return $this->response;
}
}
You can do using plugin.
Create around method on execute()
over class MagentoSalesControllerOrderHistory
and redirect to 404 page.
Plugin Class
<?php
namespace StackexchangeTestPlugin;
class HistoryPlugin
{
/**
* @var MagentoFrameworkAppActionContext
*/
private $context;
private $response;
private $redirect;
/**
* @var MagentoFrameworkUrlInterface
*/
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkUrlInterface $url
)
{
$this->context = $context;
$this->response = $context->getResponse();
$this->redirect = $context->getRedirect();
$this->url = $url;
}
public function aroundExecute(
MagentoSalesControllerOrderHistory $object,
callable $proceed
){
$norouteUrl = $this->url->getUrl('noroute');
$this->getResponse()->setRedirect($norouteUrl);
return;
}
/**
* Retrieve response object
*
* @return MagentoFrameworkAppResponseInterface
*/
public function getResponse()
{
return $this->response;
}
}
edited yesterday
answered yesterday
Amit Bera♦Amit Bera
57.3k1474170
57.3k1474170
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
it will not work ? why it require code if funcnality is already there ?
– Minesh Patel
yesterday
add a comment |
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
it will not work ? why it require code if funcnality is already there ?
– Minesh Patel
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday
it will not work ? why it require code if funcnality is already there ?
– Minesh Patel
yesterday
it will not work ? why it require code if funcnality is already there ?
– Minesh Patel
yesterday
add a comment |
Create di.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginName" type="VendorModulePluginOrderHistory" />
</type>
</config>
Create the plugin file
<?php
namespace VendorModulePluginOrder;
class History
{
private $context;
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
) {
$this->resultRedirectFactory = $context->getResultRedirectFactory();
$this->resultFactory = $context->getResultFactory();
$this->url = $url;
}
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
$resultRedirect = $this->resultFactory->create(MagentoFrameworkControllerResultFactory::TYPE_REDIRECT);
$norouteUrl = $this->url->getUrl('noroute');
$result = $resultRedirect->setUrl($norouteUrl);
return $result;
}
}
add a comment |
Create di.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginName" type="VendorModulePluginOrderHistory" />
</type>
</config>
Create the plugin file
<?php
namespace VendorModulePluginOrder;
class History
{
private $context;
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
) {
$this->resultRedirectFactory = $context->getResultRedirectFactory();
$this->resultFactory = $context->getResultFactory();
$this->url = $url;
}
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
$resultRedirect = $this->resultFactory->create(MagentoFrameworkControllerResultFactory::TYPE_REDIRECT);
$norouteUrl = $this->url->getUrl('noroute');
$result = $resultRedirect->setUrl($norouteUrl);
return $result;
}
}
add a comment |
Create di.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginName" type="VendorModulePluginOrderHistory" />
</type>
</config>
Create the plugin file
<?php
namespace VendorModulePluginOrder;
class History
{
private $context;
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
) {
$this->resultRedirectFactory = $context->getResultRedirectFactory();
$this->resultFactory = $context->getResultFactory();
$this->url = $url;
}
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
$resultRedirect = $this->resultFactory->create(MagentoFrameworkControllerResultFactory::TYPE_REDIRECT);
$norouteUrl = $this->url->getUrl('noroute');
$result = $resultRedirect->setUrl($norouteUrl);
return $result;
}
}
Create di.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginName" type="VendorModulePluginOrderHistory" />
</type>
</config>
Create the plugin file
<?php
namespace VendorModulePluginOrder;
class History
{
private $context;
private $url;
public function __construct(
MagentoFrameworkAppActionContext $context,
) {
$this->resultRedirectFactory = $context->getResultRedirectFactory();
$this->resultFactory = $context->getResultFactory();
$this->url = $url;
}
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
$resultRedirect = $this->resultFactory->create(MagentoFrameworkControllerResultFactory::TYPE_REDIRECT);
$norouteUrl = $this->url->getUrl('noroute');
$result = $resultRedirect->setUrl($norouteUrl);
return $result;
}
}
edited yesterday
answered yesterday
Rohan HapaniRohan Hapani
1
1
add a comment |
add a comment |
Hope this will help you.
You need to add the following code in di.xml
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginOrderHistory"
type="VendorModulePluginOrderHistory"
sortOrder="10"
disabled="false"/>
</type>
Then you need to add the following code in VendorModulePluginOrderHistory
History.php
<?php
namespace VendorModulePluginOrder;
use MagentoFrameworkExceptionNotFoundException;
class History
{
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
// your custom code after the original execute function
if ($returnValue) {
throw new NotFoundException(__('Parameter is incorrect.'));
}
return $returnValue;
}
}
?>
Thanks
add a comment |
Hope this will help you.
You need to add the following code in di.xml
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginOrderHistory"
type="VendorModulePluginOrderHistory"
sortOrder="10"
disabled="false"/>
</type>
Then you need to add the following code in VendorModulePluginOrderHistory
History.php
<?php
namespace VendorModulePluginOrder;
use MagentoFrameworkExceptionNotFoundException;
class History
{
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
// your custom code after the original execute function
if ($returnValue) {
throw new NotFoundException(__('Parameter is incorrect.'));
}
return $returnValue;
}
}
?>
Thanks
add a comment |
Hope this will help you.
You need to add the following code in di.xml
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginOrderHistory"
type="VendorModulePluginOrderHistory"
sortOrder="10"
disabled="false"/>
</type>
Then you need to add the following code in VendorModulePluginOrderHistory
History.php
<?php
namespace VendorModulePluginOrder;
use MagentoFrameworkExceptionNotFoundException;
class History
{
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
// your custom code after the original execute function
if ($returnValue) {
throw new NotFoundException(__('Parameter is incorrect.'));
}
return $returnValue;
}
}
?>
Thanks
Hope this will help you.
You need to add the following code in di.xml
<type name="MagentoSalesControllerOrderHistory">
<plugin name="YourPluginOrderHistory"
type="VendorModulePluginOrderHistory"
sortOrder="10"
disabled="false"/>
</type>
Then you need to add the following code in VendorModulePluginOrderHistory
History.php
<?php
namespace VendorModulePluginOrder;
use MagentoFrameworkExceptionNotFoundException;
class History
{
public function aroundExecute(MagentoSalesControllerOrderHistory $subject, Closure $proceed)
{
$returnValue = $proceed();
// your custom code after the original execute function
if ($returnValue) {
throw new NotFoundException(__('Parameter is incorrect.'));
}
return $returnValue;
}
}
?>
Thanks
answered yesterday
ShankarShankar
355
355
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257052%2fhow-to-redirect-page-to-404-in-magento2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Add the URL to index.php to get 404 not found
– PMPD
yesterday
Can it possible by url rewrite?
– Rutvee Sojitra
yesterday
You can redirect using .htaccess too.
– Vivek
yesterday
you can add in default URL rewrite as custom url(Admin Panel Menu Marketing ->SEO & Search ->URL Rewrites )
– Minesh Patel
yesterday