如何重定向请求从一个域来子目录无形? [英] How to redirect request coming from a domain to a subdirectory invisibly?

查看:226
本文介绍了如何重定向请求从一个域来子目录无形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重定向从example.com来一个子目录中的所有请求。下面的code实现这一点,但我不能让子目录不可见。 (该子目录包含一个Drupal实例,有自己的/ htaccess文件。莫非是问题吗?)

I am trying to redirect all requests coming from example.com to a subdirectory. The code below accomplishes this but I cannot make the subdirectory invisible. (The subdirectory contains a Drupal instance with its own/htaccess file. Could that be the problem?)

  RewriteCond %{HTTP_HOST} ^example.com$ [NC]

  RewriteRule ^(.*)$ http://example.com/drupal/d6/$1 [L]

这最终看起来像这样在浏览器:

This ends up looking like this in the browser:

http://example.com/drupal/d6/install.php?外形=默认

编辑:我试着从重写规则移除 http://example.com 的建议,但重定向仍不可见的。 : - (

I tried removing http://example.com from the RewriteRule, as recommended, but the redirect is still not invisible. :-(

推荐答案

这是绝对URL将导致重定向。只使用一个路径:

An absolute URl will cause a redirect. Use just a path:

RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteCond $0 !^drupal/d6/
RewriteRule .* drupal/d6/$0 [L]

这篇关于如何重定向请求从一个域来子目录无形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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