Forum Moderators: phranque
I am trying to put a 301 redirect up to redirect spiders and customers on a website.
At the moment the current products are viewed in detail using a url like this.
http://www.domain.com/viewProduct?productID=AAAA55555
And the new page which displays the product detail is: -
http://www.domain.com/products/AAAA55555.html
Now so far I have the following but I can't seem to get it to work?
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*viewProducts\.php?\ HTTP/ [NC]
RewriteRule ^(.*)viewProducts?productID=$ products/$1.html [R=301,L]
Any suggestions?
PS.
The re-write for the first url I typed is below
RewriteRule ^products/(AA(AB¦CD¦EF)[0-9]{5})\.html$ view_detail.php?product_id=$1 [NC,L]
I posted that at about 6:30 this morning when I couldnt sleep!
At the moment the client has a website, and to view products in detail the URL is...
http://www.domain.com/viewProduct.php?productID=AAAA55555
With the re-development and SEO optimising I have started to completely overhall the site, and now I have the new url like this...
http://www.domain.com/products/AAAA55555.html
This is the URL that browsers point to. This is provided using a re-write which is...
RewriteRule ^products/(AA(AB¦CD¦EF)[0-9]{5})\.html$ view_detail.php?product_id=$1 [NC,L]
It basically makes it look as if there is a static .html page for each product, whereas it is actually parsed on the fly by calling the view_detail.php file passing the variable product_id in the query string.
This is setup and working fantastically, but when we put the new site online we will end up being penalised for the search engines as the page no longer exists for the products. The last thing we want is to go lower in the rankings (as the aim is to travel in the opposite direction...Upwards!).
So what I am trying to do is setup a 301 redirect so that the search engine spiders log the fact the page no longer exists (301) and to be redirected to the new product page.
To achieve this I have started to write the condition for it, but cannot get my head around it!
Here is what I have...
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*viewProducts\.php?\ HTTP/ [NC]
RewriteRule ^(.*)viewProducts?productID=$ products/$1.html [R=301,L]
As you may not be able to see I am trying to redirect ALL requests to the old page...
http://www.domain.com/viewProducts.php?productID=AAA55555
to the new page
http://www.domain.com/products/AAAA55555.html
Does this make more sense?
Thankyou and apologies for the poor explanation to start!
At the moment the current products are viewed in detail using a url like this.http://www.example.com/viewProduct?productID=AAAA55555
Now so far I have the following but I can't seem to get it to work?
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*viewProducts\.php?\ HTTP/ [NC]
RewriteRule ^(.*)viewProducts?productID=$ products/$1.html [R=301,L]The re-write for the first url I typed is below
RewriteRule ^products/(AA(AB¦CD¦EF)[0-9]{5})\.html$ view_detail.php?product_id=$1 [NC,L]
There's a technical problem with your redirect rule, but there's no use discussing it until we know the correct /consistent details.
Jim
[edited by: jdMorgan at 3:26 pm (utc) on Nov. 30, 2007]
Lack of sleep within 48 hours and caffeine levels are making my concentration extremely low.
Appologies guys, I know for you to help me, I have to help you!
Right.... 3rd attempt
Here is what I have...
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*viewProduct\.php?\ HTTP/ [NC]
RewriteRule ^(.*)viewProduct?productID=$ products/$1.html [R=301,L]
As you may not be able to see I am trying to redirect ALL requests to the old page...
http://www.domain.com/viewProduct.php?productID=AAA55555
to the new page
http://www.domain.com/products/AAAA55555.html
Does this make more sense?
# Internally rewrite new static URLs to dynamic filepath
RewriteRule ^products/(AA(AB¦CD¦EF)[0-9]{5})\.html$ /view_detail.php?product_id=$1 [NC,L]
#
# Externally redirect (only) direct client requests for dynamic URLs to corresponding static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /viewProduct\.php\?productID=([^&\ ]*)\ HTTP/ [NC]
RewriteRule ^viewProduct\.php$ http://www.example.com/products/%1.html[b]?[/b] [NC,R=301,L]
[edit] Corrected as noted below [/edit]
[edited by: jdMorgan at 4:56 pm (utc) on Dec. 29, 2007]
yeah I had got confused myself between viewProduct and viewProducts lol....
It is fine, however it is now appending?productID=AAAA00000 to the end of the new page's url.
EG.
[domain.com...]
How can I get it not to do this?