Domanda

IIS 6, using IIRF. I'm not sure if this would be a rewrite or a redirect. We've got a new site and need to 301 redirect old page to new and keep the query string value only. I need the following rewrite rule. This stuff is kind of hard to work with and I couldn't find any examples that match what I'm trying to do.

I need this to rewrite based on a specific URL:

subdomain.site.org/dir1/dir2/dir3/page.cfm?pc=1092

When this page is hit, I need it to rewrite to the following:

subdomain2.site.org/detail.aspx?id=1092

Notice that it doesn't pull the whole query string, just the value of it.

È stato utile?

Soluzione

Since you want to redirect with a 301 to a new (permanent) URL, you should use a RedirectRule.

Assuming you have a single web site which is configured to respond to subdomain.site.org and to subdomain2.site.org, you will need a RewriteCond in order to only redirect requests from the old subdomain.

RewriteCond %{SERVER_NAME} ^subdomain\.site\.org$
RedirectRule ^/dir1/dir2/dir3/page\.cfm\?pc=(\d+)$ http://subdomain2.site.org/details.aspx?id=$1 [I,R=301]

The RedirectRule finally only executes if the old URL pattern is matched, and restitutes the query string value of pc to the new URL.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top