OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How can I implement masking and forwarding of a url on Wordpress?

  • Thread starter Thread starter Latifah President
  • Start date Start date
L

Latifah President

Guest
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

Code:
<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

Code:
# 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

Code:
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.
<p>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.</p>
<p>So far I've installed a file manager plugin to get access to the htaccess file. I added this to the file</p>
<pre><code><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>
</code></pre>
<p>I've also tried adding this</p>
<pre><code># 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
</code></pre>
<p>And this to the functions.php file in the theme/divi etc folder</p>
<pre><code>
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');
</code></pre>
<p>I'm able to be redirected but the masking isn't working.</p>
Continue reading...
 
Top