Forum Moderators: phranque
Have hundreds of old dynamic URLs in SERPs that look like:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?&pg=cat&ref=something
They need redirect 301 to:
http://www.example.com/cat--something-else--really_something.html
In some case (many actually) we have renamed categories too.
Those are category URLs, our old page URLs are like this:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?pg=page
New page URLs:
http://www.example.com/page----page.html
Old product URLs:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?pg=prod&ref=prod
New product URLs:
http://www.example.com/item--good-stuff-to-buy--prod.html
I have tried many different ways with both redirect 301 and RewriteRule, but no love for me.
Our current .htaccess rewrite rules look like this:
#ATS SEO Rules
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^cat--(.*)\.html /ccp51/cgi-bin/cp-app.cgi?seo=cat--$1
RewriteRule ^item--(.*)\.html /ccp51/cgi-bin/cp-app.cgi?seo=item--$1
RewriteRule ^page--(.*)\.html /ccp51/cgi-bin/cp-app.cgi?seo=page--$1
RewriteRule ^store /ccp51/cgi-bin/cp-app.cgi?pg=store
RewriteRule ^splash /ccp51/cgi-bin/cp-app.cgi?pg=splash
#RewriteRule ^$ /ccp51/cgi-bin/cp-app.cgi
#End ATS SEO Rules
If I can get a blanket rule to 301 the old dynamics and the right rule structure to redirect 301 for the old category dynamics that now have new names... well then I might be able to get some sleep. ;)
If you can give me a real example? If those are then I'm not sure?
Those are category URLs, our old page URLs are like this:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?pg=pageNew page URLs:
http://www.example.com/page----page.htmlOld product URLs:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?pg=prod&ref=prodNew product URLs:
http://www.example.com/item--good-stuff-to-buy--prod.html
What is with all the hyphens? Are they supposed to be there? The product URLs is what's confusing?
You want /cgi-bin/cp-app.cgi?pg=prod&ref=prod to turn into: item--good-stuff-to-buy--prod.html?
Maybe this just went over my head? But another explaination with a real example with what a new real url would look like would be great.
Jim
You can check out the ATS page at that link and find example sites showing the types of URLs generated. You can tell by the truncation that the URLs are generated. In fact, if I change the description of the product, the URL changes too.
Except for the 'example.com', these are real:
Category old:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?&pg=cat&ref=chokers
Category new:
http://www.example.com/cat--Sexy-Chokers--chokers.html
Product old:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?pg=prod&ref=EM-9178
Product new:
http://www.example.com/item--EM-9178-School-Girl-Mini-Skirt-W/-V--EM-9178.html
Page old:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?pg=specials
Page new:
http://www.example.com/page----specials.html
You'll note that if we do not use any display name or description, the URLs default to '----' in the middle as opposed to '--cute-title--'. Our script automatically puts a hyphen in word spacings appearing in the title/description. Product URLs use the first 35 characters of the item description too (we start our descriptions with the product id). So if we have a product:
ID: EM-9235
Name: Sexy Stuff
Description: Really sexy stuff you should buy now!
The URL generated by our script will be:
http://www.example.com/item--EM-9235-Really-sexy-stuff-you-shoul--EM-9235.html
So the problem is the hundreds of old style URLs out there that won't 404 and are resisting redirection 301 -- especially the categories we renamed. The script just presents a blank category page, our menu and header appear on every page, but there is nothing where the cgi get calls call the elements. If it's a product page not found, the sytem just generates a page that says the product wasn't found, try another menu item etc.
So I have a lot of 301s to do, but I can't make any Redirect 301 RedirectMatch permanent or RewriteRule work yet.
Thanks... hope someone can enlighten me. I've spent two days pulling what is left of my hair out ;)
I've tried many of the examples I found on the net including the page you linked to and other posts of yours, nothing working yet for me.
I've managed to get a couple of 'forbiddens' and 'internal server errors', but otherwise nothing.
It usually doen't take me more than a few hours to figure something out, but this one is a twister.
Thanks..
I set up a test by creating some folders on the server to represent the same number of path divisions:
http://www.example.com/pros/test/
I put a page called swimwear.html in the test folder. Then I started playing with stuff like:
rewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)/(.*)/(.*)swimwear\ HTTP/
rewriteRule ^(.*)/(.*)/(.*)swimwear$ / [R=301,L]
That works fine regardless if I use the actual folder names or not, so I know I have basic functions.
So next I started giving requests adding segments of the real URL I want to redirect to -- thereby exposing the evil ones that rally to stop me. The question mark >>>? <<< stops me.
The request it needs to process and redirect is:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi?&pg=cat&ref=swimwear
It works if I request this:
http://www.example.com/ccp51/cgi-bin/cp-app.cgi&pg=cat&ref=swimwear
but not the actual. The only difference is that the second one is missing the '?'. So I have to find a way to translate, crush, kill.. destroy that evil smirking question mark. I tried backslash '\?' -- no love. After I figure out how to make this work around the '?', I'll be able to write what I need (maybe).
So I'll keep playing. But if anyone knows exactly how I can pack some willie peter into that little question mark and vanquish it, please shout it out. I've been reading lots about this stuff, but haven't really found good data and examples yet about translating that little '?'.
I've tried using the query string stuff too. Nothing yet.
#redirects
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^&pg=cat&ref=swimwear$
RewriteRule ^ccp51/cgi\-bin/cp\-app\.cgi$ /cat--Sexy-Swimwear--sexy_swimwear.html? [R=301,L]
#end redirects
So that will probably become the foundation for the rest of my sleepless, evil, geeky deeds............ ;)