Support » Fixing WordPress » Question on index.php

  • Hi!

    This is probably a very dumb question. I’ve done a bit of searching around the forums and Google for an answer to this. Didn’t come up with anything.

    I have wordpress up and running on an Nginx web server. Everything works — permalinks, etc etc. In my Nginx configuration file, I have a snippet such as this which is the equivalent to Apache’s mod_rewrite rules:

    —–8<———
    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?q=$1 last;
    }
    —–8<———

    My question is, how does this work? More specifically, I know that with the rule in place, a URL like http://myblog/path/to/post gets rewritten internally and I am shown the correct post. So shouldn’t that mean without such a rewriting rule, if I use a URL like http://myblog/index.php?q=path/to/my/post I should get the correct post?

    But I don’t. It doesn’t seem to work. Any ideas why? Is the index.php?q=whatever bit not meant to be called directly? I just wanted to confirm that bit first before I look into the Nginx side and figure if that’s where I should probe more …

    Thanks and Regards,
    Rakhesh

Viewing 2 replies - 1 through 2 (of 2 total)
  • honewatson

    (@honewatson)

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Normally, rewrites don’t change the path into a q= variable. WordPress is not looking for the q variable, so your rewrite rule won’t work.

    An internal rewrite keeps the same URL but actually calls the index.php file. I don’t know where the q= stuff came from.

    Google tells me that this might work:

    if (!-e $request_filename) {
            rewrite ^/.*$ /index.php last;
        }

    Inside the server {…} bit.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Question on index.php’ is closed to new replies.