重定向时出现 htaccess 错误 - 重定向次数过多
我正在尝试将所有请求从一个域 (domain.co.in) 重定向到另一个域 (domain.info.in)。我已经在 htaccess 中尝试过重写指令和重定向指令,但在浏览器中出现太多重定向错误。以下是我尝试实现的配置。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.in [NC]
RewriteRule ^(.*)$ index.php/$1
RewriteRule ^(.*)$ http://domain.info.in/$1 [R,L]
我实际工作的 htaccess 配置是
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php/$1
使用这个,我能够将所有请求重定向到 index.php 并且工作正常。但是当我添加域重写规则时,我收到重定向错误。我也尝试过重定向指令, 重定向 302 / http://domain.info.in/index.php/$1
,但同样的错误。
我尝试了本文中提到的 Fiddler 工具,调试 .htaccess 重写的提示规则。在那里它工作得很好。
实际上,我想重定向所有请求(www.domain.co.in,domain.co.in ,www.domain.info.in) 到domain.info.in
对此有什么建议吗?
I'm trying to redirect all requests from one domain (domain.co.in) to another domain (domain.info.in). I've tried Rewrite directives and Redirect directive in htaccess, but getting too many redirects error in browser. Below is the configuration I'm trying to implement.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.in [NC]
RewriteRule ^(.*)$ index.php/$1
RewriteRule ^(.*)$ http://domain.info.in/$1 [R,L]
My actual working htaccess configuration is
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php/$1
Using this, I'm able to redirect all requests to index.php and working fine. But when I add domain rewrite rules, I'm getting the redirect error. I've tried Redirect directive also,Redirect 302 / http://domain.info.in/index.php/$1
, but same error.
I tried the Fiddler tool mentioned in this post, Tips for debugging .htaccess rewrite rules. There it is working good.
Actually, I want to redirect all requests (www.domain.co.in, domain.co.in, www.domain.info.in) to domain.info.in
Any suggestions on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 @CBroe 的建议,我已经更新了配置并且它可以工作。正如他所说,
我还在检查中添加了否定,以重定向所有其他请求。
As per @CBroe's suggestion, I've updated the configuration and it works. As he said,
And I've also added negation to the checking to redirect all other requests.