Francis Daly
January 11, 2020 09:20AM
On Sat, Jan 11, 2020 at 08:35:02AM -0500, tconlon wrote:

Hi there,

> Found it,
>
> if ($page == 'index.php') {
> header("Location: ". $toUrl);
>
> probably need something like this
>
> <?php
> // 301 Moved Permanently
> header("Location: ",TRUE,301);

Good that you have found a straightforward solution.

An alternative, which would involve different changes, and would depend
on the actual urls that have been advertised, could be to make a list of
id/city pairs once, and use nginx's "map" to do the translation without
touching the index.php.

Something like, in the "http" block:

map $request_uri $slug_city {
/location/index.php?id=235 newyorkcity;
# more lines like that
}

and then inside the location that normally handles that request (which
I think is "location ~ \.php$ {"

add

if ($slug_city) { return 301 /location/$slug_city; }

That may or may not be clearer to whoever is going to maintain the system
in the future.

Cheers,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Force 302 to 301 redirect

tconlon January 10, 2020 03:03PM

Re: Force 302 to 301 redirect

cooley.josh@gmail.com January 10, 2020 03:11PM

Re: Force 302 to 301 redirect

tconlon January 10, 2020 03:17PM

Re: Force 302 to 301 redirect

Francis Daly January 10, 2020 06:04PM

Re: Force 302 to 301 redirect

tconlon January 11, 2020 08:29AM

Re: Force 302 to 301 redirect

tconlon January 11, 2020 08:35AM

Re: Force 302 to 301 redirect

Francis Daly January 11, 2020 09:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 309
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