Php 请求根目录时,htaccess重定向与域屏蔽不起作用
需要使用.htaccess实现重定向+域屏蔽的帮助。它部分地起作用了。它适用于子页面和子目录,但不适用于域本身 我有两个域“redir1”和“redir2”。 目标是通过.htaccess和掩蔽实现重定向,如下所示:Php 请求根目录时,htaccess重定向与域屏蔽不起作用,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,需要使用.htaccess实现重定向+域屏蔽的帮助。它部分地起作用了。它适用于子页面和子目录,但不适用于域本身 我有两个域“redir1”和“redir2”。 目标是通过.htaccess和掩蔽实现重定向,如下所示: http://redir2 —> http://redir1 http://redir2/sub.php —> http://redir1/sub.php http://redir2/index.php —> http://redir1/index.php 显示
http://redir2 —> http://redir1
http://redir2/sub.php —> http://redir1/sub.php
http://redir2/index.php —> http://redir1/index.php
显示给访问者的url必须保持他们输入的内容:
http://redir2
http://redir2/sub.php
http://redir2/index.php
但是如果他们输入http://redir1
他们应该看到http://redir1
在url中
每个域有以下两个文件:
index.php
sub.php
以下是.htaccess中的代码:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?redir2$ [NC]
RewriteRule ^ http://redir1%{REQUEST_URI} [L,NE,P]
对于域之后有内容的所有请求(子页面和子目录),它都工作得很好。例如:
http://redir2/sub.php
http://redir2/index.php
但是如果我只输入http://redir2/
我收到一个“未找到”错误:
实际上,我没有index.html,但我有index.php
如何在不添加index.html的情况下解决此问题
谢谢也许可以用redir2 htaccess文件中的
DirectoryIndex.php
?DirectoryIndex.php
解决问题。然而,关于Wordpress的一个小提示。如果redir1
是Wordpress网站,它有自己的标准访问说明。它还带来了其他问题。例如,它可能会屏蔽子页面ok。但它不会屏蔽域,只会在不屏蔽的情况下重定向到redir1。
The requested URL /index.html was not found on this server.