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