WordPress overrides the GET variables, (page_id) set in HTACCESS

I have a wordpress site that is extremely large and pushing WordPress to its limits. It uses a number of pages/categories and a lot of .htaccess rules to organise the various sections of the site, (it’s for a large magazine).

One particular issue is really stumping me. I have the following rules in .htaccess …

Read More
RewriteRule ^(cat|tag)/([^/]+)(/?)$ index.php?page_id=3&s1=$2 [L,QSA]
RewriteRule ^xyz/([^/]+)(/?)$ index.php?page_id=6&s1=$1 [L,QSA]

Now, if the argument supplied to the cat/tag page has no trailing slash, it always works. If the argument has a trailing slash, and the tag in question matches the entries in a non-Wordpress table that work with the ‘xyz’ page, WordPress loads that page instead, even if the tag is present.

I have tested that the rules always work, and they do. WordPress is always getting the correct $_GET[‘page’] of 3 and the tag slug as $_GET[‘s1’], and yet decides to show a different page altogether if the above is true.

Everything is done within .htaccess, permalinks in wordpress are turned off completely. How can I stop WP form deciding against the page_id it has been told to use.

Related posts

Leave a Reply

1 comment

  1. WordPress’ URL routing is really difficult to work with. I’m looking forward to the day it’s replaced with something more rational (and I hope that I get to be the one to write the code to replace it, but I digress…)

    However I think your first problem is trying to do everything in .htaccess. I’ve probably got more experience with URL design and URL rewriting than anyone else I know and I really wouldn’t try to fight WordPress with .htaccess; you are most likely only going to get the kind of results that are currently driving you crazy. Instead I’d try to manage URL routing from within WordPress and using hooks for when you need to override something WordPress is doing really screwy.

    However, for me to fully understand what you are trying to accomplish and prescribe a proper solution I’d want to see a full map of URLs you have on your site and those that you want.

    Finally I’ve linked some related Q&As below. They are not directly answering your question but they might give you some insight and the last one is about scaling WordPress for high traffic.