Php 如果主机通过htaccess与某些主机列表匹配,则在内部重定向
当我的主机名与某个主机或正则表达式列表匹配时,我希望在内部重定向到站点中的不同目录/模块 例如Php 如果主机通过htaccess与某些主机列表匹配,则在内部重定向,php,.htaccess,codeigniter-3,Php,.htaccess,Codeigniter 3,当我的主机名与某个主机或正则表达式列表匹配时,我希望在内部重定向到站点中的不同目录/模块 例如 http://fa.foo.com/controller/action/params应在内部重定向到http://fa.foo.com/module_name/controller/action/params 请在下面找到我的代码和配置 操作系统:Windows 10(64位) Mod_Rewrite:我在Apache中启用了Mod_Rewrite模块 Codeigniter版本:3.1(HMVC体系
http://fa.foo.com/controller/action/params
应在内部重定向到http://fa.foo.com/module_name/controller/action/params
请在下面找到我的代码和配置
操作系统:Windows 10(64位)
Mod_Rewrite:我在Apache中启用了Mod_Rewrite模块
Codeigniter版本:3.1(HMVC体系结构)
PHP版本:5.6.32
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Codeigniter default redirect config. This works perfectly fine.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# My code for the above scenario.
RewriteCond %{HTTP_HOST} ^fa.foo.com$
RewriteRule ^(.*)$ %{HTTP_HOST}/index.php/module_name/$1 [L]
</IfModule>
使用上面的htaccess代码,系统抛出下面的apache错误
[Fri Apr 30 13:07:25.163464 2021] [core:error] [pid 6200:tid 1916] [client 127.0.0.1:64947] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
我肯定我错过了什么。任何建议/帮助都将不胜感激
如果需要任何其他信息,请告诉我
谢谢 这目前完全没有任何实际的问题描述。(如果你现在想说“不行”,请去读。)谢谢@CBroe非常感谢您抽出时间来回答这个问题,非常感谢。我已经更新了问题。请你具体指出缺失的内容,我一定会尽力更新。再次感谢!为什么替换URL以
%{HTTP\u HOST}/
开头?您正在通过匹配^(.*)$
重定向“所有内容”,这将再次匹配已重写的URL。您需要执行一项检查,检查当前URL路径是否已经以您想要重定向到的路径开始,否则您将得到一个无止境的循环。@CBroe%{HTTP\u HOST}/
被添加到指向主机的路径。我已经把它去掉了。不过,情况还是一样。是的,我意识到,你能帮助我如何添加支票以避免太多重定向吗?我对.htaccess
配置不太熟悉。那将非常感激。谢谢
[Fri Apr 30 13:07:25.163464 2021] [core:error] [pid 6200:tid 1916] [client 127.0.0.1:64947] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.