htaccess的重定向与请求的根目录时域掩蔽不工作 [英] htaccess redirect with domain masking not working when requesting root directory

查看:303
本文介绍了htaccess的重定向与请求的根目录时域掩蔽不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助实现重定向​​+域中的.htaccess屏蔽。这部分工作。它适用于子页和子目录,但不是域本身。

Need help with achieving redirection + domain masking with .htaccess. It is partially working. It works for sub–pages and sub-directories but not the domain itself.

我有两个域redir1和redir2。 我们的目标是实现重定向​​与的.htaccess和屏蔽是这样的:

I have two domains "redir1" and "redir2". The goal is to achieve redirection with .htaccess and masking like this:

http://redir2 —> http://redir1
http://redir2/sub.php —> http://redir1/sub.php
http://redir2/index.php —> http://redir1/index.php

和URL显示访客必须保持他们进入了什么:

And url displayed to visitor has to remain what they entered:

http://redir2
http://redir2/sub.php
http://redir2/index.php

但是,如果他们进入的http:// redir1 他们应该看到的http:// redir1 在网址

But if they entered http://redir1 they should see http://redir1 in url.

每个域有以下两个文件:     的index.php     sub.php

each domain has two following files: index.php sub.php

下面是code在.htaccess:

Here is the code in .htaccess:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?redir2$ [NC]
RewriteRule ^ http://redir1%{REQUEST_URI} [L,NE,P]

这是工作非常好有域(子页和子目录)后,所有的东西要求。例如:

It is working very well for all requests that have something after domain (sub-pages and sub-directories). For example:

http://redir2/sub.php
http://redir2/index.php

但是,如果我输入只是的http:// redir2 / 我得到一个未找到错误:

But if I type in just http://redir2/ I get a "Not found" error:

The requested URL /index.html was not found on this server.

事实上,我没有index.html的,但我的index.php 如何在不增加index.html的解决这一问题?

Indeed I don't have index.html but I have index.php How to solve the issue without adding index.html?

感谢

推荐答案

也许有的DirectoryIndex的index.php

这篇关于htaccess的重定向与请求的根目录时域掩蔽不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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