如何为共享子目录的子域设置重定向 [英] How to set up redirect for subdomain that shares the subdirectory

查看:105
本文介绍了如何为共享子目录的子域设置重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个子目录来在Linux x86-Apache 2.2.x上托管我的wordpress网站.我还设置了一个子域来指向它.站点完成后,我将主域指向该子目录.但是现在我需要将子域重定向到域.我怎样才能做到这一点?我尝试将301重定向添加到.htaccess:

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.

任何帮助将不胜感激!

推荐答案

似乎您对.htaccess重定向有正确的想法.

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.

如果可以,可以使用天鹅绒蓝调之类的工具进入管理员. 否则&或者,如果您想做更全面的工作,我建议您使用此独立的无配置必需工具,即使使用了非​​标准WP表,该工具也会更新数据库中的所有引用:

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

这篇关于如何为共享子目录的子域设置重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆