问题描述
是否有办法跟踪哪个文件导致重定向?尽管我在htaccess中定义了301重定向,但我的网站仍通过302重定向从非www版本重定向到www版本。该文件似乎被忽略。
is there a way to trace which file causes a redirection? My website redirects from non-www to www version with a 302 redirect, eventhough I defined a 301 redirect in my htaccess. The file seems to be ignored.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^dreadfactory\.de$ [NC]
RewriteRule ^(.*)$ http://www.dreadfactory.de/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
即使我将规则更改为.com结束时,我仍然重定向到www.dreadfactory.de。看来,该文件已被完全忽略。我试图一个接一个地禁用每个插件和主题,然后检查了核心文件的更改。
Even if I change the rule to a .com ending, I'm still redirected to www.dreadfactory.de. So it seems, that the file is completely ignored. I tried to disable every plugin and the theme one by one and I checked the core files for changes.
是否有任何方法可以跟踪从哪个位置/文件进行重定向
Is there any way to trace from which position/file the redirect is called?
- 更新:
I刚刚发现了一些其他重定向问题:所有非www网址都重定向到网站的根目录。 dreadfactory.de/angebot被重定向到 www.dreadfactory.de。那是非常不寻常的,我还没有发现为什么会发生这种情况。
I just discovered some more redirect issues: all non-www urls are redirected to the root of the website. "dreadfactory.de/angebot" is redirected to "www.dreadfactory.de". That's quite unusual and I have not yet discovered why that is happening...
推荐答案
我建议您将其添加到您的 VirtualHost
/ htaccess
。记录 mod_rewrite
的活动。
I would suggest you to add this in your VirtualHost
/htaccess
. To log the activities of mod_rewrite
. It Will be helpful for debugging and higher the RewriteLogLevel
better for debugging.
RewriteEngine On
RewriteLog "/path/to/your/rewrite.log"
RewriteLogLevel 3
来自:
我建议您使用 RewriteLogLevel 9
。但是在完成调试后,请降低该级别。
I would suggest you to use RewriteLogLevel 9
. But do reduce the level after you are done debugging.
这篇关于跟踪重定向源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!