Forum Moderators: phranque

Message Too Old, No Replies

Dynamic .htaccess Redirect Problem

htaccess dynamic link redirect

         

flagtothefloor

7:53 pm on Dec 22, 2006 (gmt 0)

10+ Year Member



Hello- this should be pretty easy, I'm just not an .htaccess expert.

I built a new site, but the browsers and other websites link to my product pages using a query string link with old filenames. I need to redirect the queries to use the new filenames.

How would I create this redirect?

Example
----------

Old Site:

[domain.com...]

New Site:

[domain.com...]

I've tried this:

Options +FollowSymlinks
RewriteEngine On

RewriteRule ^Product.aspx?SKU=([^/\.]+)/?$ /product_info.php?products_id=$1 [L]

and it doesn't seem to work. What am I doing wrong?

Thanks,
Rob

jdMorgan

8:31 pm on Dec 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Query strings are not part of a URL; They are data attached to a URL to be passed to the resource at that URL. Therefore, query strings are not visible to RewriteRule.

Use a RewriteCond with the %{QUERY_STRING} variable to test and/or back-reference query strings.

Note that the "?" serves only to delineate the URL from the query string, and will appear in neither the RewriteRule URL-path nor the %{QUERY_STRING} value.

See Note: Query String following the Apache mod_rewrite RewriteRule documentation [httpd.apache.org]

Jim