WordPress 重写重定向失败

发布于 2024-08-07 00:49:02 字数 878 浏览 7 评论 0原文

我正在帮助一位朋友从外包 WordPress 网站给他造成的混乱中恢复过来(错误#1),但我遇到了这个奇怪的错误。他使用的主机似乎会自动将 www.domain.com 重定向到domain.com(为什么是 NFI),这在除 IE 之外的每个浏览器中都可以正常工作(我知道是对的!)。因此,添加第一个重定向解决了这个问题,直到我添加了永久链接重定向。现在,当 IE 转到旧的 WordPress 链接时,例如 http://www.domain.com/?p= 520 重定向失败。

RewriteEngine On
RewriteBase /

# Rewrite rule for wierd redirect issue
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^/?(.*)$ "http\:\/\/doman\.com\/$1" [R=301,L]

# Rewrite Rule for Wordress Permalinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

我用 wget 对此进行了测试,它抱怨:

ERROR: Redirection (301) without location.

因此 IE 似乎也遇到了相同的错误(没有有用的错误消息)。但我不知道如何解决它。我希望他会更换托管公司,但我们拭目以待。同时有什么想法吗?

I'm helping a friend recover from the mess outsourcing a wordpress website caused him (mistake #1) and I have this weird error. The hosting he is using appears to be redirecting www.domain.com to domain.com (NFI why) automatically which works fine in every browser except IE (i know right!). So adding the first redirect fixed that, until I added the permalink redirect. Now when IE goes to an old wordpress link like http://www.domain.com/?p=520 the redirect fails.

RewriteEngine On
RewriteBase /

# Rewrite rule for wierd redirect issue
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^/?(.*)$ "http\:\/\/doman\.com\/$1" [R=301,L]

# Rewrite Rule for Wordress Permalinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I tested this out with wget and it complains:

ERROR: Redirection (301) without location.

So it seems likely that IE is suffering from the same error (without the helpful error message). But I haven't a clue how to fix it. I am hoping that he will switch hosting companies but we will see. In the meantime any ideas?

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

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

发布评论

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

评论(2

半夏半凉 2024-08-14 00:49:02

我会回答为什么“www.domain.com”是“domain.com”,
第三方开发者必须参与弃用 www 运动

基本上,它不应该影响任何浏览器。我确实建议重置您的缓存和/或刷新您的 DNS。

尝试删除:

# Rewrite rule for wierd redirect issue
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^/?(.*)$ "http\:\/\/doman\.com\/$1" [R=301,L]

重新上传然后查看它是否正常工作。如果没有,请删除您的缓存。刷新看看是否可以正常使用。如果仍然不行,请尝试刷新您的 DNS。

如果您使用 Windows,则可以从命令提示符刷新 DNS。

这些是我采取的步骤:

  1. 开始
  2. 运行
  3. Cmd
  4. ipconfig /flush-dns

对于任何其他操作系统,我不确定如何刷新 DNS。

当我切换域名主机时,我通常会采取这些预防措施,但这可能是相关的,因为它与域相关。希望有帮助。

我还想补充一点,常规的 Wordpress .htaccess 文件如下所示:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

因此,如果其他方法都失败,只需用基本的 Wordpress .htaccess 代码替换所有内容即可。

祝你好运 :)

I will answer why "www.domain.com" was "domain.com",
the 3rd party developer must have been under the deprecated www movement.

Basically, it shouldn't have affected any of the browsers. I do suggest resetting your cache and or flushing your dns.

Try removing:

# Rewrite rule for wierd redirect issue
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^/?(.*)$ "http\:\/\/doman\.com\/$1" [R=301,L]

Reupload then see if it works properly. If not, delete your cache. Refresh to see if it works properbly. And if it still not, try flushing your DNS.

If you using Windows, you can flush your DNS from the Command Prompt.

These are the steps I take:

  1. Start
  2. Run
  3. Cmd
  4. ipconfig /flush-dns

For any other O.S. I am unsure how to flush the DNS.

I usually take these precautions when I switch hosts for the domain name but this may be related as it is domain related. Hope that helps.

I also want to add that a regular Wordpress .htaccess file looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

So if all else fail, just replace everything with the basic Wordpress .htaccess code.

Good Luck :)

败给现实 2024-08-14 00:49:02

你可能应该尝试

RewriteRule (.*) http://domain.com/$1 [R=301,L]

You should probably try with

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