Welcome! Log In Create A New Profile

Advanced

Re: Pages rewrite

Francis Daly
January 26, 2016 05:52PM
On Fri, Jan 22, 2016 at 01:00:31PM -0500, blason wrote:

Hi there,

> I need a help on below topic and I wanted to achieve URL Rewrite like this
>
> We want to redirect our domain pages from source to destination one
>
> Source : Original Page
> www.xxxx.com/index.php?id=news
>
> Destination :
> www.xxxxx.com/news.html

Option 1 - do it in php.

Write an index.php that will issue suitable 301 redirects for whatever
arguments it gets.

Option 2 - do it in nginx.conf.

In your "location = /index.php" block, use the appropriate logic.

If you know you will always get exactly one "id" parameter that will
always map to the obvious new url, something like

return 301 /$arg_id.html;

(untested) would probably work. If you have different logic -- what
should happen with a request for /index.php?id=news&key=value, or for
/index.php?id1=news, or for /index.php?id=news&id=help, or for /index.php
-- then when you describe your intention, it may become obvious how to
implement it.

If it is straightforward, then http://nginx.org/r/map and examples
may help; if it is not, you may find it simpler to work in a different
language such as php.

(Note: in the above I have assumed that the source and destination
hostnames are the same. If they really are not, and the number of x's is
intentionally different, then you would need to include the full http://
url in the return directive.)

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Pages rewrite

blason January 22, 2016 01:00PM

Re: Pages rewrite

blason January 26, 2016 02:02AM

Re: Pages rewrite

Francis Daly January 26, 2016 05:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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