【问题标题】:code in .htaccess does not redirect properly.htaccess 中的代码未正确重定向
【发布时间】:2014-12-22 04:51:05
【问题描述】:

我的 .htaccess 文件中有以下代码

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.8mags\.com [NC]
RewriteRule ^(.*) http://8mags.com/$1 [L,R=301]

在firefox中显示以下错误

The page isn't redirecting properly

这个重定向代码写在文件的顶部。重定向代码下面是chaching和gzip压缩的代码,最后是404重定向代码

ErrorDocument 404 http://8mags.com/404page.html

这是怎么回事?

【问题讨论】:

  • 您的 htaccess 中有更多规则吗?如果是,请在此处发布。

标签: php apache .htaccess redirect


【解决方案1】:

试试这个:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^8mags.com
RewriteRule ^(.*)$ http://8mags.com/$1 [R=permanent,L]
RewriteCond %{REQUEST_URI} /index\.html?$ [NC]
RewriteRule ^(.*)index\.html?$ "/$1" [NC,R=301,NE,L]
</IfModule>

ErrorDocument 404 /404.html

我已经在我的项目中实现了这个类似的代码。

【讨论】:

  • 我被重定向到8mags.com/404page.html 这个帐户上托管了两个域名,这可能是个问题吗?
  • 不,它不是经销商帐户
猜你喜欢
  • 1970-01-01
  • 2018-06-08
  • 2013-06-28
  • 1970-01-01
  • 1970-01-01
  • 2020-09-03
  • 1970-01-01
  • 2019-02-09
  • 1970-01-01
相关资源
最近更新 更多