Wordpress Nginx config PHP code question

If you set up a wordpress blog on a LEMP, you have the following snippet in the configuration for the virtual host:

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

I believe I understand how it works. When you surf to http://www.mywordpressblog.com/cat/this-is-a-post.

It first tries to find cat/this-is-a-post in the documentroot. If not found, it tries cat/this-is-a-post/

If this doesn't work it passes some arguments $args to the index.php file.

Question: How do I access the value(s) in $args from within the php code in index.php?

The thing is I want to get hold of the "/cat/this-is-a-post" string, which I can via $SERVER["REQUESTURI"], but I want to know what is in $args as well.

pannix

2 Replies

I haven't tested it out but I supposed it would be in the $_GET array in PHP?

No, the $_GET array is empty.

Trying to read some documentation on this but it gives me a headache, maybe the value of $args is supposed to end up in $SERVER["REQUESTURI"]?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct