Roger
Roger

Reputation: 8586

PHP/NGINX: 301 redirect

I was making a temporary redirect in PHP changing the headers.

However I'd like to make now a simple 301 page redirection directly in Nginx:

http://domain.com/example.php?var=value

to:

http://domain.com/index.htm

I tried:

location / {
    index index.htm index.php;
    rewrite example.php?var=value / permanent;
}

But it is not working...

Any ideas?

Thanks.

Upvotes: 1

Views: 2270

Answers (1)

Roger
Roger

Reputation: 8586

Simply put (out of "location / {}"):

rewrite /example.php?var=value / permanent;

By the way, PHP has a way to make redirections 301 also.

Upvotes: 4

Related Questions