admin管理员组

文章数量:1122832

I'm trying to implement forward and masking of a url. I have a page hosted on vercel as mynewpage.vercel.app. The rest of my page are hosted on Wordpress on myotherpages. I want for when the user types in myotherpages/newpage or navigates there from the nav bar for them to be forwarded to mynewpage.verce.app, but have the url in the address appear as myotherpages/newpage. I'm using the divi theme for all the other pages.

So far I've installed a file manager plugin to get access to the htaccess file. I added this to the file

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^myotherpages\$ [NC]
    RewriteCond %{REQUEST_URI} ^/myotherpages/newpage/?$
    
    RewriteRule ^myotherpages/newpage/?$ / [P,L]
</IfModule>

<IfModule mod_proxy.c>
    ProxyPass /myotherpages/newpage 
    ProxyPassReverse /myotherpages/newpage 
</IfModule> 

I've also tried adding this

# BEGIN Custom Redirect and Masking
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/myotherpages/newpage$
RewriteRule ^/myotherpages/newpage$  [R=302,L]
# END Custom Redirect and Masking

And this to the functions.php file in the theme/divi etc folder


function custom_redirect_my_new_page() {
    if (is_page('myotherpages/newpage')) {
        wp_redirect('');
        exit();
    }
}
add_action('template_redirect', 'custom_redirect_my_new_page');

本文标签: redirectForward and mask implementation not working