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 ?

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

报告相同问题?

悬赏问题

  • ¥20 uniapp中的webview 使用的是本地的vue页面,在模拟器上显示无法打开
  • ¥15 网上下载的3DMAX模型,不显示贴图怎么办
  • ¥15 关于#stm32#的问题:寻找一块开发版,作为智能化割草机的控制模块和树莓派主板相连,要求:最低可控制 3 个电机(两个驱动电机,1 个割草电机),其次可以与树莓派主板相连电机照片如下:
  • ¥15 Mac(标签-IDE|关键词-File) idea
  • ¥15 潜在扩散模型的Unet特征提取
  • ¥15 iscsi服务无法访问,如何解决?
  • ¥15 感应式传感器制作的感应式讯响器
  • ¥15 如何使用SC92F8003固件库解析私有协议数据?
  • ¥15 如何在音频中嵌入字符串(水印)信息进行传递
  • ¥30 plc怎么以设计说明书申请软著