使用 htaccess 进行 301 重定向文本模式

发布于 2024-08-28 08:16:55 字数 657 浏览 3 评论 0原文

尝试为域更改设置 301 重定向。我正在使用已经进行了 mod 重写的 Textpattern。添加重定向时,系统会在网站上提示我一个错误页面,指出该页面导致了太多重定向!

这是正在使用的 htaccess 文件...

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /relative/web/path/

RewriteRule (.*) http://www.domain.com/$1 [R=301,L] #(this has been added to the default textpattern htaccess file)

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]

RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php

RewriteCond %{HTTP:Authorization}  !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

非常感谢您提供的任何建议。

Trying to set up a 301 redirect for a change in domain. I'm using Textpattern which already has a mod rewrite. When adding the redirect I'm prompted with a error page on the site, stating that the page has resulted in too many redirects!

This is the htaccess file in use...

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /relative/web/path/

RewriteRule (.*) http://www.domain.com/$1 [R=301,L] #(this has been added to the default textpattern htaccess file)

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]

RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php

RewriteCond %{HTTP:Authorization}  !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

Many thanks for any advise you can give.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奶气 2024-09-04 08:16:55

您尝试从哪个域重定向?可能您已设置循环 - 尝试从 site.com 重定向到 site.com?

From what domain you try to redirect? May be you have set cycling - trying to redirect from site.com to site.com?

我也只是我 2024-09-04 08:16:55

在 RewriteEngine On 之后添加此内容

RewriteCond %{HTTP_HOST} ^(?!www.yournewdomain.com$).*$
RewriteRule (.*) http://www.yournewdomain.com/$1 [R=301,L]

Add this after RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?!www.yournewdomain.com$).*$
RewriteRule (.*) http://www.yournewdomain.com/$1 [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文