doulutian4843 2015-03-27 17:56
浏览 38
已采纳

在请求根目录时,域掩码的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.

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

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

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

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

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

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

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.

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

Thanks

  • 写回答

1条回答 默认 最新

  • dsl36367 2015-03-27 18:07
    关注

    Maybe with DirectoryIndex index.php ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊