Reputation: 456
I know this is a subject that comes up a lot, so I'll just make sure everyone knows: I have read and tried many of the rewrite suggestions on here already, with no luck.
I have a WordPress install (nginx server, virtual machine w/ apache) that's running just fine, but there's an issue with directories + queries in the URL. If the directory does not have a trailing slash before the query, it does not resolve (bounces back to blog index).
Example:
www.example.com/blog/?=generic_query works just fine.
www.example.com/blog?=generic_query does not.
Unfortunately, the theme I've installed (X-Theme) has some admin menus that point to pages without the trailing slash on the directory before the query.
I have tried to rewrite the conditions within htaccess but I just haven't had any success. I've read others saying that PHP usually doesn't care at all about this, so the fact that this is making a fuss with this strange nginx install makes me wonder if it's a server issue.
Does anyone have any suggestions for this very specific issue? It'd be much appreciated if so!
Thank you
--
Edit: Putting my root htaccess file here.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Upvotes: 1
Views: 86
Reputation: 4302
Put this in .htaccess
file :
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,7}\s/(.*?)([^\/])\?(.*)\sHTTP.*$
RewriteRule ^(.*)$ /%1%2/?%3 [L]
Second lime will check if the request has no /
before ?
.
Third line will add it to request internally .
UPDATE :
Save your previous rules and put this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{THE_REQUEST} /blog(/)?\?(.*)\sHTTP.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog/index.php [L]
</IfModule>
# END WordPress
Upvotes: 2