Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Apache中的重定向循环_Html_.htaccess_Http_Ubuntu_Apache2 - Fatal编程技术网

Html Apache中的重定向循环

Html Apache中的重定向循环,html,.htaccess,http,ubuntu,apache2,Html,.htaccess,Http,Ubuntu,Apache2,我试图将目录的位置(例如,www.example.com/dir)转发到文件本身,例如,www.example.com/dir/file.php)。以下是我的.htaccess配置: Redirect /dir http://example.com/dir/file.php. 我以这种方式得到一个重定向循环: example.com/dir/file.php/file.php/file.php/+...+file.php ad nauseam. 这个逻辑相当新,所以很明显我可能遗漏了一些东

我试图将目录的位置(例如,
www.example.com/dir
)转发到文件本身,例如,
www.example.com/dir/file.php
)。以下是我的
.htaccess
配置:

Redirect /dir http://example.com/dir/file.php. 
我以这种方式得到一个重定向循环:

example.com/dir/file.php/file.php/file.php/+...+file.php ad nauseam.

这个逻辑相当新,所以很明显我可能遗漏了一些东西。

重定向指令是前缀匹配,匹配后的所有内容(即
/file.php
)都附加到目标URL的末尾,因此重定向循环

但是,您可以改为使用
RedirectMatch
,它匹配特定的正则表达式,而不是简单的前缀匹配。例如:

RedirectMatch ^/dir$ /dir/file.php