Changing the entire permalink

So for the case where you want to change “lesson” to “learn”, there’s actually a “rewrite” option you could use, if you were the one registering the new post type. Since you are not, however, you have to be a little bit more crafty.

Thankfully, WP gives you a hook to modify the post registration arguments before it registers it, so you can modify your plugin’s implementation:

function change_lesson_rewrite_rule($args, $post_type) {
    if(isset($args['rewrite']) && is_array($args['rewrite'])) $args['rewrite']['slug'] = 'learn';
    else $args['rewrite'] = array('slug' => 'learn');
    return $args;
}
add_filter('register_post_type_args', 'change_lesson_rewrite_rule', 1000, 2);

I’ve given your filter a high priority (1000) to make sure it’s one of the last ones to affect the arguments array.

As for changing the whole domain to another, that would not work – and wouldn’t be a good idea… Rewrites only work for the path part of a URL. The domain is your site’s address, you can’t change that – unless you want people to end up on a totally different site! 😉

UPDATE

Ok, so it seems you instead have physical pages (static or php) that you would like to show visitors, that are not served through WordPress. In this case, the rewrite rules in .htaccess already allow this. All you need is to place your files in your root folder. In your case:

...
wp-config.php
wp-content
...
learn/ <---- create this folder
    lesson1.php <---- place your files here

This will allow people to view the URL https://[site name]/learn/lesson1.php

UPDATE 2

Based on your latest comments, you have two options: you can do a Apache rewrite or you can use WordPress’ template_redirect hook. The Apache solution might run a bit faster, but both versions will work:

Apache rewrite option

In your site’s .htaccess file, you could add this block (I’d add it before WP’s block)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^lesson/(.*)$ /learn/$1 [R=301,NC,L]
</IfModule>

template_redirect option

Alternatively, you can do the redirect from within WordPress’ code. In your theme functions.php file, you could add:

function my_page_template_redirect() {
    if(preg_match('/\/lesson\/(.*?)$/', $_SERVER['REQUEST_URI'], $matches)) {
        wp_redirect(home_url('/learn/'.$matches[1]));
        exit();
    }
}
add_action('template_redirect', 'my_page_template_redirect');

Hope this helps!