• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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