0

Either using wp-pagenavi or the standard wp pagination (posts_nav_link()) a click to mydomain.com/page/2 will result in a 301 redirect back to the home page (url = domain.com )

This is not a duplicate, the other post talks nothing about redirects. Also, my wp_query seems fine, as it works with pretty permalinks off. Also, this whole thing works on at least one site with identical plugins and theme, etc.

UPDATE: http://domain.com/category/validCategory/page/2/ does work...

turning off pretty permalinks and using ?page=2 works.

Yes, I am using

$args['paged'] = get_query_var( 'page' );
$wp_query = new WP_Query( $args );
$posts = $wp_query->posts;

to modify the posts.

if I make it

$args['paged'] = 2;

It will show the second page of posts, but on the home page.

Yes, I have read several articles about not using a new query, but have determined that it is better for me if I do.

However, this redirection is happening before it ever gets to this, afaik. I'm sticking a die() in there but it doesnt die until it's redirected, and dies on the home page.

Nothing in my htaccess would do this

php_value max_execution_time 3600
#php_flag display_errors on
#php_value error_reporting 7
php_value upload_max_filesize 20M
php_value post_max_size 20M

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


RewriteRule ^wp-content/uploads/(.*) /uploads/$1 [QSA,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

This is a new problem, only occuring on a couple of sites out of many that are running on identical installs. I dont see any differences between working and non working.

So, if no one has the easy answer, where do I start to debug and find out where wp is deciding it needs to redirect to home?

9
  • I fixed it with the template_redirect filter: mydigitallife.info/… But I'd love some more explanation as to why. Commented Jun 3, 2013 at 3:36
  • Yes, I have read several articles about not using a new query, but have determined that it is better for me if I do. There is no legitimate reason I can imagine where doing this is necessary. Move whatever query modification you need to do into a function hooked to pre_get_posts, do not modify the query in the template.
    – Milo
    Commented Jun 3, 2013 at 5:08
  • answer #7 of wordpress.stackexchange.com/questions/50761/… However, I'm pretty sure it has nothing to do with the problem. Commented Jun 3, 2013 at 14:14
  • again, it is normally not necessary and not advised to do it that way when using pre_get_posts is much simpler. the issue is that the main query and your template query are totally unrelated. WordPress decides whether or not to send a 404 and if a redirect is necessary based on the results of the main query, which happens long before the template is ever loaded. in some cases, like displaying posts on the page post type, you'll find it works ok, but in many cases it doesn't.
    – Milo
    Commented Jun 3, 2013 at 15:46
  • why you find it works in some installs and not others is not because of theme or plugin differences, it's because the content is different, so the results of the default main query are different.
    – Milo
    Commented Jun 3, 2013 at 15:47

0

Browse other questions tagged or ask your own question.