• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Resolved 301-Redirect

othmaqsa

Regular Pleskian
Server operating system version
Ubuntu 20.04.5 LTS
Plesk version and microupdate number
Version 18.0.47 Update #2
Hello,

I can't find the option on Plesk to create a 301-Redirect.

What I want to do is to create several permanent redirects (example: redirect a visitor from www.mysite.com/products/a to www.mysite.com/product/a) in order to remove all "404 not found" errors in the search console)

Thanks for your help.
 
301 redirects are created in the sites .htaccess file e.g.
Code:
Redirect 301 /oldpage.html https://www.example.com/newpage.html
 
301 redirects are created in the sites .htaccess file e.g.
Code:
Redirect 301 /oldpage.html https://www.example.com/newpage.html
Hello @Dave W ,

I use NGINX. I forgot to mention it.

There is any any directive which can solve this ?

Thank you in advance.
 
- Go to Websites & Domains > Your Subscription > Apache & nginx Settings
- Scroll down to the "Additional nginx directives" section
- Add the following code to the text box provided, using the target domain instead of example.com

Code:
return 301 https://example.com$request_uri;
 
Hello,

I found a solution which consists of placing this code in functions.php and replacing /old-slug and /new-slug with the appropriate values.

Code:
function quadlayers_redirect() {

if (isset($_SERVER['HTTPS']) &&
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
$currenturl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$currenturl_relative = wp_make_link_relative($currenturl);

switch ($currenturl_relative) {

case '/old-slug':
$urlto = home_url('/new-slug');
break;

default:
return;

}

if ($currenturl != $urlto)
exit( wp_redirect( $urlto ) );
}
add_action( 'template_redirect', 'quadlayers_redirect' );
 
Back
Top