views:

486

answers:

2

I'm currently using an htaccess file to redirect users from

detail.asp?CategoryID=XX&SubCategoryID=XX&ProductID=XX

to

catid-XX-subcatid-xx-productid-xx

but I now need to check they've arrived at the correct page. I'm doing this by checking that the query string values are correct. However I'd rather check that the user arrived at "catid-XX-subcatid-xx-productid-xx" so that Google doesn't index duplicate content.

So what I'm wondering is if there's a way of finding out the string from the URL bar before the htaccess rewrite.

If I'm on a page

catid-XX-subcatid-xx-productid-xx

then using VBScript, if I check

Request.ServerVariables("URL") & Request.ServerVariables("QUERY_STRING")

I get

detail.asp?CategoryID=XX&SubCategoryID=XX&ProductID=XX

Is there any way of getting the correct URL string?

A: 

This reminds me of something like this;

var i = 1+1;
/* lets double check to make sure the cpu has calculated it right.. 
   just in case, I mean, you never know... */

if (i != 2) return ZOMG END OF THE WORLD!!
Gary Green
not so much, its vitally important that only URL is the final URL otherwise Google would index 2 pages with the same content. This causes sites to get marked down by Google and if it happens a lot, it can kill search engine rankings.
ewengcameron
+1  A: 

The environment variable REQUEST_URI should contain the requested URI.


You could try to use PATH_INFO and parse the requested URI path with ASP:

RewriteRule !^detail\.asp detail.asp%{REQUEST_URI} [L]

The requested URI path should then be available in:

Request.ServerVariables("PATH_INFO")
Gumbo
That would be perfect but unfortunately I'm stuck using VBscript which doesn't have an equivalent function. Should have made that clear in the question. Thanks!
ewengcameron
It’s the server that provides this environment variable. So “Request.ServerVariables("REQUEST_URI")” doesn’t work?
Gumbo
Yeah, if i call it in PHP it returns the correct URI, however it's not supported in ASP so returns an empty string.
ewengcameron