通过htaccess将子域重定向到子目录 [英] Redirecting subdomain to subdirectory through htaccess

查看:49
本文介绍了通过htaccess将子域重定向到子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试通过 htacess 将子域重定向到子目录..

I've been trying to redirect a subdomain to a subdirectory through htacess..

我有一个域可以说 sub.domain.com 和目录 domain.com/site/我想将 sub.domain.com 重定向到 domain.com/site 而不更改任何 url,只需以 SEO 友好的方式重定向.

I have a domain lets say sub.domain.com and the directory domain.com/site/ I want to redirect sub.domain.com to domain.com/site not changing any url, simply redirecting in a SEO friendly way.

我尝试了重定向 301 规则,但似乎没有奏效.

I've tried a redirect 301 rule but it doesn't seem to have worked.

推荐答案

在您的 .htaccess 中试试这个:

Try this in your .htaccess:

RedirectMatch 301 wiki.comp.tf(.*) comp.tf/wiki$1

如果这不起作用,另一种选择是:

If that does not work, an alternative option is:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^wiki.comp.tf
RewriteRule ^(.*)$ http://comp.tf/wiki$1 [L,NC,QSA]

使用真实姓名的一些潜在选项:

Some potential options for you using actual names:

Redirect 301 wiki.comp.tf comp.tf/wiki

这篇关于通过htaccess将子域重定向到子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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