I set up a subdirectory to host my wordpress site on Linux x86-Apache 2.2.x. I also set up a subdomain to point to it. Once the site was complete, I pointed the primary domain to the that subdirectory. But now I need to redirect the subdomain to the domain. How can I accoplish this? I tried adding a 301 redirect to .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:www\.)?subdomain.domain1\.com$
RewriteRule ^(.*)$ http://www.domain2.net/subfolder$1
but this just broke all my links on the domain.
Any help would be appreciated!
Ok. Here is the general info about Apache Virtual Hosting https://httpd.apache.org/docs/2.4/vhosts/name-based.html
And here is the example with Ubuntu 16.04 (you can google any other). It is very easy, just follow the instructions.
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
The point is you need to search info about VIRTUAL HOSTs (Apache).
It looks likes you've got the right idea for the .htaccess redirect.
You'll now need to update all the links in your site to point to the new domain otherwise there's a chance you'll just create infinite redirect loops.
If, you can get into your admin you could use a tool like Velvet blues otherwise & or if you want to do a more comprehensive job, I'd recommend using this standalone no-config required tool which updates all references in your database even if there are non-standard WP tables in use: interconnect/it