我为什么要获得重定向循环?

Joh*_*han 2 apache .htaccess http http-status-code-301

我有一个网站,例如(http://example.com).我希望将任何请求/例如http://example.com重定向到http://example.com/stuff.我添加了一个.htaccess文件,其中包含以下行:

redirect 301 / http://example.com/stuff
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

Dav*_*itt 5

请参阅Redirect指令的文档:

然后,以URL-Path开头的任何请求都将向目标URL位置的客户端返回重定向请求.匹配的URL-Path之外的其他路径信息将附加到目标URL.

用一个RedirectMatch代替:

RedirectMatch 301 ^/$ http://example.com/stuff
Run Code Online (Sandbox Code Playgroud)

  • 使用"wget -S"来调试它.浏览器可能会缓存重定向. (3认同)