Andrew Martin
September 11, 2013 09:34AM
Francis,

Using the similar statement "try_files $uri $uri/ /index.php;", if I visit
this URL:
http://mysite.com/index.php?title=my_test_page
then the URL is rewritten to this, but it just loads the contents of
index.php (without the title variable):
http://mysite.com/my_test_page
What it shows would be equivalent to going to this page:
http://mysite.com/index.php

The part of my nginx configuration which communicates with php is:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}

The php code is a custom page, not a pre-built CMS. It is doing an ajax
call to load the content, but should be functionally-equivalent to this:
<html>
<head></head>
<body>
<!-- header code here -->
<?php
if (isset($_GET['title'])) {
include($_GET['title'] . ".html");
} else {
include("home.html");
}
?>
<!-- footer code here -->
</body>
</html>

If I go to this page:
http://mysite.com/index.php?title=my_test_page
I would like the client's browser to instead show this URL:
http://mysite.com/my_test_page

Does this help clarify what I am looking for?

Thanks,

Andrew


On Wed, Sep 11, 2013 at 7:43 AM, Francis Daly <francis@daoine.org> wrote:

> 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?
>
> Yes.
>
> Use something like
>
> if ($arg_title != "") {
> return 302 http://mysite.com/$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.
>
> f
> --
> Francis Daly francis@daoine.org
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite URL to only show value of $_GET argument

Andrew Martin September 09, 2013 12:04AM

Re: Rewrite URL to only show value of $_GET argument

mex September 09, 2013 02:58AM

Re: Rewrite URL to only show value of $_GET argument

edogawaconan September 09, 2013 05:00AM

Re: Rewrite URL to only show value of $_GET argument

Andrew Martin September 09, 2013 08:54AM

Re[2]: Rewrite URL to only show value of $_GET argument

artem September 09, 2013 09:06AM

Re: Re[2]: Rewrite URL to only show value of $_GET argument

Andrew Martin September 09, 2013 09:26AM

Re: Re[2]: Rewrite URL to only show value of $_GET argument

Francis Daly September 10, 2013 12:48PM

Re: Re[2]: Rewrite URL to only show value of $_GET argument

Andrew Martin September 10, 2013 10:10PM

Re: Re[2]: Rewrite URL to only show value of $_GET argument

Francis Daly September 11, 2013 08:44AM

Re: Re[2]: Rewrite URL to only show value of $_GET argument

Andrew Martin September 11, 2013 09:34AM

Re: Re[2]: Rewrite URL to only show value of $_GET argument

Francis Daly September 11, 2013 10:32AM

Re: Re[2]: Rewrite URL to only show value of $_GET argument

Andrew Martin September 16, 2013 06:50AM

Re: Rewrite URL to only show value of $_GET argument

GreenGecko September 19, 2013 07:54PM

Re: Rewrite URL to only show value of $_GET argument

Andrew Martin September 20, 2013 12:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 245
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready