How to set up redirect for subdomain that shares t

2019-09-15 07:58发布

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!

2条回答
手持菜刀,她持情操
2楼-- · 2019-09-15 08:23

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).

查看更多
SAY GOODBYE
3楼-- · 2019-09-15 08:30

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

查看更多
登录 后发表回答