WordPress中令人讨厌的重定向循环(尾部斜杠,没有尾部斜杠,等等)

时间:2010-06-14 06:50:31

标签: wordpress

我阅读了大量的网页并尝试了很多解决方案,但还没有一个工作过!

我的问题是:

test.asifa.net/asifa-wp

重定向至:

test.asifa.net/asifa-wp /

哪个重定向到第一页。

asifa-wp产生的有点奇怪:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://test.asifa.net/asifa-wp/">here</a>.</p>
</body></html>

asifa-wp /产生一个空页面但是下面的标题(curl -v输出):

* About to connect() to test.asifa.net port 80 (#0)
*   Trying 69.163.203.138... connected
* Connected to test.asifa.net (69.163.203.138) port 80 (#0)
> GET /asifa-wp/ HTTP/1.1
> User-Agent: curl/7.18.2 (i386-redhat-linux-gnu) libcurl/7.18.2 NSS/3.12.0.3 zlib/1.2.3 libidn/0.6.14 libssh2/0.18
> Host: test.asifa.net
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Sun, 13 Jun 2010 05:40:12 GMT
< Server: Apache
< X-Powered-By: PHP/5.2.13
< X-Pingback: http://test.asifa.net/asifa-wp/xmlrpc.php
< Set-Cookie: _icl_current_language=en; expires=Mon, 14-Jun-2010 05:40:12 GMT; path=/asifa-wp/
< Location: http://test.asifa.net/asifa-wp
< Vary: Accept-Encoding
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8

.htaccess看起来像:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /asifa-wp/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /asifa-wp/index.php [L]

</IfModule>

# END WordPress

任何帮助都会非常感激!!!

2 个答案:

答案 0 :(得分:1)

<?php
/*
Plugin Name: Disable Canonical URLs
Description: Disable Canonical URLs
Version: .1
Author: Aaron
Author URI: http://aahacreative.com/
*/

remove_filter('template_redirect', 'redirect_canonical');
?> 

尝试将其保存到.php文件并在wordpress安装上激活它。

答案 1 :(得分:1)

我知道这是一篇很老的文章,但只是为了帮助社区。我通过删除/%postname%/

中的斜杠解决了这个问题

enter image description here