Okay, so I have URL rewriting set up on my server (IIS 7) so that, for example,
http://example.org/p/1234/
is really
http://example.org/product/?product_id=1234
(With /product/ containing an index file for a web app that's able to process the query params).
The problem is, I want everyone to use the /p/1234/
urls now, so I'd like to send a 301 redirect whenever someone visits the old url of /product/?product_id=1234
, but as far as I can tell when URL rewriting occurs, as far as the server is concerned the user did go to /product/?product_id=1234
.
Although in the browser's URL bar it may say http://example.org/p/1234/
, when I do a dump of headers and CGI variables, /p/1234/
doesn't show up in any of the variables.
I guess my concern is, even if I can do this, it seems like it would make a simple request fairly convoluted:
- Go to
/p/1234/
- Rewrite it to
/product/?product_id=1234
- Was it originally
/p/1234/
? (yes) - Do nothing.
And otherwise:
- Go to
/product/?product_id=1234
- Was it originally
/p/1234/
? (no) - 301 Redirect to
/p/1234/
- Rewrite it to
/product/?product_id=1234
- Was it originally
/p/1234/
? (yes) - Do nothing.
I know that eventually some search indexes will eliminate the old URLs in favor of the ones specified by the 301 redirect, but until then it seems like a lot of overhead for the servers.
Also, if I did set this up, is there a filter I could use in IIS to do this, or would I need to add the logic to my webapp?
Note that I have set up <link rel="canonical".../>
for all of these webpages but I still see the old format showing up in search results.
X-Original-URL
. Still curious about the impact of using 301 redirects in this case.