doulutian4843 2015-03-27 09: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 10:07
    关注

    Maybe with DirectoryIndex index.php ?

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

报告相同问题?

悬赏问题

  • ¥40 selenium访问信用中国
  • ¥15 电视大赛投票系统的c语言代码怎么做
  • ¥20 在搭建fabric网络过程中遇到“无法使用新的生命周期”的报错
  • ¥15 Python中关于代码运行报错的问题
  • ¥500 python 的API,有酬谢
  • ¥15 软件冲突问题,软件残留问题
  • ¥30 有没有人会写hLDA,有偿求写,我有一个文档,想通过hLDA得出这个文档的层次主题,有偿有偿!
  • ¥50 有没有人会写hLDA,有偿求写,我有一个文档,想通过hLDA得出这个文档的层次主题,有偿有偿!
  • ¥15 alpha101因子里哪些适合crypto?
  • ¥15 ctrl win alt 键一直触发
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部