Reputation: 1
I'm trying to implement forward and masking of a url. I have a page hosted on vercel.com as mynewpage.vercel.app. The rest of my page are hosted on Wordpress on myotherpages.com. I want for when the user types in myotherpages.com/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.com/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\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/myotherpages.com/newpage/?$
RewriteRule ^myotherpages.com/newpage/?$ https://mynewpage.vercel.app/ [P,L]
</IfModule>
<IfModule mod_proxy.c>
ProxyPass /myotherpages.com/newpage https://mynewpage.vercel.app
ProxyPassReverse /myotherpages.com/newpage https://mynewpage.vercel.app
</IfModule>
I've also tried adding this
# BEGIN Custom Redirect and Masking
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/myotherpages.com/newpage$
RewriteRule ^/myotherpages.com/newpage$ https://mynewpage.vercel.app [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.com/newpage')) {
wp_redirect('https://mynewpage.vercel.app');
exit();
}
}
add_action('template_redirect', 'custom_redirect_my_new_page');
I'm able to be redirected but the masking isn't working.
Upvotes: 0
Views: 28