Rewriting a subdomain page on one WordPress installation to a parent domain on another

How can I use .htaccess to rewrite a a page on a subdomain to a page on the parent? (E.g. people visiting mysite.com/landingpage will see the content from dev.mysite.com/landingpage)?

Ive been working to redesign a WordPress site, using a dev.mysite.com subdomain. The site isn't ready to replace the live WP site yet (mysite.com) but I need to map one of the pages to the old domain and make it public. Since all the work (template,database,etc) is on the subdomain, I can't just import the page to the old domain, so I seemingly need to use mod_rewrite, which is way beyond my skill level. Also, since its two different WP Installations (not multisite), would I use the domain .htaccess file or the subdomain .htaccess file?

Thanks!

Topic subdomains url-rewriting htaccess Wordpress

Category Web


You seem to be speaking of URL masking. Please refer here and here for examples.

A visitor to example.com/mypage can be shown example.net/mypage while seeing example.com/mypage in the address bar. Not sure how you'd handle the links from example.net/mypage back to the main site instead of the development site, but that wasn't part of the question.


If you use the main domain .htaccess file when people go onto the page you want to display on the sub domain it will change the url link to dev.mysite.com I am not sure if that is the best approach but if you want to do it that way you would have to use the main domains .htaccess to redirect to the subdomain.

Another option could be export the page's data with a WordPress exporting plugin. A search on the website led me to this one which may be of some use. https://en-gb.wordpress.org/plugins/wp-exporter/

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.