htaccess的重写子域 [英] htaccess rewrite to sub-domain

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

问题描述

您好我有一个在主服务器的一个子目录位于一个独立的网站。

Hi I have a independent site that sits within a sub-directory of a main server.

子目录网站内点到根的所有链接,我想捕捉那些,并将它们发送回子目录,而不是根目录。

All links within the sub-directory site point to the root and I'd like to capture those and send them back to the sub-directory rather than the root.

这可能与htaccess的?

Is this possible with htaccess?

推荐答案

这不会重定向到子目录,但要其他域的行为就好像子目录是文档根。我认为这是更好的。

This will not redirect to the subdir, but make the other domain behave as if the subdir is the document-root. Which I think is even better.

RewriteEngine on
RewriteBase     /

RewriteCond %{HTTP_HOST} ^seconddomain.nl$ [NC]
RewriteCond $1 !^subfolder
RewriteRule ^(.*)$ /subfolder/$1 [L]

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

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