# Permanent Redirect

**URL:** <https://www.ruby-forum.com/t/permanent-redirect/187341>\
**Category:** NGINX\
**Created:** [April 21, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/permanent-redirect/187341 "2010-04-21T22:19:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![openstream](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/48db29/32.png) [@openstream](https://www.ruby-forum.com/u/openstream)\
**Post date:** [April 21, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/permanent-redirect/187341/1 "2010-04-21T22:19:28Z")

</div>

Hi there,

I’m trying to permanently redirect various outdated URLs to the domain’s  
home page like so:

location /phpshop {  
rewrite ^ [http://www.my-domain.com](http://www.my-domain.com) permanent;  
}

which results e.g. in

[http://www.my-domain.com/phpshop/?page=shop/flypage&product\_id=65](http://www.my-domain.com/phpshop/?page=shop/flypage&product_id=65)

to be rewritten to

[http://www.my-domain.com?page=shop/flypage&product\_id=65](http://www.my-domain.com?page=shop/flypage&product_id=65)

which kind of makes sense, but I need to strip those parameters (page  
and product\_id), too.

Any ideas on how to accomplish this?

Here’s my complete virtual host configuration:

[http://openstream.pastebin.com/N09mUUef](http://openstream.pastebin.com/N09mUUef)

Any pointers would be very much appreciated.

Cheers, Nick  
Openstream Internet Solutions

> **[Deine WordPress, WooCommerce und Magento Agentur](https://www.openstream.ch/)**
>
> Seit über 15 Jahren entwickeln wir Webshops und Websites mit Open Source Shop-Systemen und E-Commerce Plattformen.

Posted at Nginx Forum:

> **[Permanent Redirect](https://forum.nginx.org/read.php?2,77780,77780#msg-77780)**
>
> Hi there, I'm trying to permanently redirect various outdated URLs to the domain's home page like so: location /phpshop { rewrite ^ http://www.my-domain.com permanent; } which results e.g. in http://www.my-domain.com/phpshop

---

<div class="post-metadata">

**Author:** ![openstream](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/48db29/32.png) [@openstream](https://www.ruby-forum.com/u/openstream)\
**Post date:** [April 21, 2010, 10:30pm UTC](https://www.ruby-forum.com/t/permanent-redirect/187341/2 "2010-04-21T22:30:00Z")

</div>

> Any ideas on how to accomplish this?

again?

---

<div class="post-metadata">

**Author:** ![openstream](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/48db29/32.png) [@openstream](https://www.ruby-forum.com/u/openstream)\
**Post date:** [April 22, 2010, 2:59am UTC](https://www.ruby-forum.com/t/permanent-redirect/187341/3 "2010-04-22T02:59:56Z")

</div>

On Tue, Apr 20, 2010 at 16:43, Nick W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://www.my-domain.com/phpshop/?page=shop/flypage&product\_id=65](http://www.my-domain.com/phpshop/?page=shop/flypage&product_id=65)
> 
> to be rewritten to
> 
> [http://www.my-domain.com?page=shop/flypage&product\_id=65](http://www.my-domain.com?page=shop/flypage&product_id=65)
> 
> which kind of makes sense, but I need to strip those parameters (page and  
> product\_id), too.

from an SEO point of view, you should make sure people get into the  
new page of that given product when using it’s old URL… or say good  
bye to your pagerank 😛

---

<div class="post-metadata">

**Author:** ![openstream](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/48db29/32.png) [@openstream](https://www.ruby-forum.com/u/openstream)\
**Post date:** [April 22, 2010, 3:04am UTC](https://www.ruby-forum.com/t/permanent-redirect/187341/4 "2010-04-22T03:04:03Z")

</div>

On Tue, Apr 20, 2010 at 04:43:19PM +0200, Nick W. wrote:

> Here’s my complete virtual host configuration:
> 
> [http://openstream.pastebin.com/N09mUUef](http://openstream.pastebin.com/N09mUUef)
> 
> Any pointers would be very much appreciated.

- location /phpshop {

- location = /phpshop/ {

- rewrite ^ [http://www.my-domain.com](http://www.my-domain.com) permanent;

- rewrite ^ [http://www.my-domain.com/](http://www.my-domain.com/)? permanent;

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![openstream](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/48db29/32.png) [@openstream](https://www.ruby-forum.com/u/openstream)\
**Post date:** [April 22, 2010, 3:12am UTC](https://www.ruby-forum.com/t/permanent-redirect/187341/5 "2010-04-22T03:12:50Z")

</div>

Hello!

On Tue, Apr 20, 2010 at 04:43:19PM +0200, Nick W. wrote:

> [http://www.my-domain.com/phpshop/?page=shop/flypage&product\_id=65](http://www.my-domain.com/phpshop/?page=shop/flypage&product_id=65)
> 
> to be rewritten to
> 
> [http://www.my-domain.com?page=shop/flypage&product\_id=65](http://www.my-domain.com?page=shop/flypage&product_id=65)
> 
> which kind of makes sense, but I need to strip those parameters  
> (page and product\_id), too.
> 
> Any ideas on how to accomplish this?

rewrite ^ [http://www.my-domain.com/](http://www.my-domain.com/)? permanent;

(note “?”)

It should be here:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

But it looks like rewrite directive description was polluted by  
lots of semi-related user notes and currently unreadable. Sombody  
has to throw/move them all away and re-translate original docs.

To all: please keep module docs / directive descriptions close to  
original docs if possible. If you think that something should be  
noted - add trailing note clearly separate from documentation, or  
even add it on separate wiki page.

Maxim D.

---

<div class="post-metadata">

**Author:** ![openstream](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/48db29/32.png) [@openstream](https://www.ruby-forum.com/u/openstream)\
**Post date:** [April 25, 2010, 3:54pm UTC](https://www.ruby-forum.com/t/permanent-redirect/187341/6 "2010-04-25T15:54:17Z")

</div>

How about this?

location /phpshop {  
rewrite ^.\*$ [http://www.my-domain.com](http://www.my-domain.com) permanent;  
}

Ray.
