Rewrite URL to only show value of $_GET argument

Francis Daly francis at
Wed Sep 11 12:43:11 UTC 2013

On Tue, Sep 10, 2013 at 09:07:46PM -0500, Andrew Martin wrote:

Hi there,

> Would it be possible to only redirect if the title $_GET variable is
> present?


Use something like

  if ($arg_title != "") {
    return 302$arg_title;

inside the "location = /index.php" block, and then continue with whatever
should happen if $arg_title is empty.

> Thanks for clarifying this. The complete behavior I'm looking for is just to
> create SEF URLs for pages on the site by hiding the index.php?title= part
> of the URL. Thus, visiting /my_test_page in your browser would internally
> load the index.php?title=my_test_page URL but display the SEF URL to
> the user. How can I achieve this behavior?

I suspect that "try_files $uri /$uri /index.php;" might be enough for
what you ask for here; if it isn't, then a description of what you do,
what you see, and what you expect to see, will probably make it easier
to understand where the problem is. (Your fastcgi-related configuration,
and the php code itself, will determine whether it is enough.)

If you search for nginx + your-php-application, do you see any
documentation on how to create SEF URLs? It may be easier than me
guessing here.

Francis Daly        francis at

More information about the nginx mailing list