I have asked this question before......and the answer for a universal mod rewrite I guess created an endless loop or whatever and it wouldn't work, unless the rule was just wrong. But I have about 7000 products, hence 7000 urls that I was rewriting a certain way and then changed the method of rewrite to include the item name in the url and shorten the url so it didn't appear that the page was deep in several directories. So I began rewiting them a different way. It now looks like they are top level pages. The jest of this is I'm trying to 301 redirect all of them to their new style. domain/cp-app/prod/sports-memorabilia/ItemID is now set to display as domain/sports-memorabilia-Item-Name--ItemId.html I made a 301 rewrite rule for each and every one to redirect them, and I think it worked, but that meant putting 7000 or so lines in my htaccess file and it ballooned to 1.5 meg in size and slowed my dynamic site to a crawl. I quickly abandoned that method. Does anyone know of a rewrite or redirect method that would work? I read briefly on webmasterworld something about a script or external from the htaccess file to accomplish this but didn't understand it at all. The bottom line is I am trying to redirect 301 a url that has been written one way to rewriting it another way. If anyone has methods or suggestions I would really really appreciate their help. If it involves a coding or script or something I am willing to pay someone for their time. I know I am not the first person who has ever changed the method of rewrite they are using for alot of urls. There must be a method that can solve this issue. I hope someone out there has the knowledge and experience to put me on the right track. Thanks in advance for your time and help!!
7000 rules? Wow, impressive. How much time does it take to produce something like that? Probably something like this will work for you: RewriteRule ^/[a-zA-Z0-9-]+--([0-9]+).html$ /shop.php?itemId=$1 [L] Code (markup): This will pick the ItemID from the url and call shop.php with the itemid as a parameter.
Post a few original URLs of some products, how they were, and how you want them!!! Odds are 99.9999% that you only need one line for them, and one line for the 301!!! How slow were the pages loading with that lany lines!!
Old rule and url RewriteRule ^cp-app/([^/]*)/sports-memorabilia/([^/]*)/?$ shop/cgi-bin/cp-app.cgi?pg=$1&sports-memorabilia&ref=$2 [L] http://www.xoxoxoxoxox.com/cp-app/prod/sports-memorabilia/HM-PHOTO323K cp-app is the cgi script, prod is the page (short for product), sports-memorabilia is just a fake dir to put those keywords in the url, ref is the item ID --------------------------------------------------------------------- New rule and url RewriteRule ^sports-memorabilia-(.*)\.html shop/cgi-bin/cp-app.cgi?seo=item--$1 [L] http://www.xoxoxoxoxoxo.com/sports-memorabilia-Jason-Varitek-Gold-Coin-Photomint--HM-PHOTO323K.html Top level page now, sports-memorabilia is again just fake keywords inserted, Jason Varitek Gold Coin Photomint is the items name or <Title> tag, HM-PHOTO323K is the itemID, and of course it now has html added to the end I need to 301 redirect anything formed in the top version if someone hits a spidered link to the new version method. I hope its doable.
Your first one has two ([^/]*), where do they both go in the new URL??!! Did all the URL's have /prod/ there?
All have prod for product. The one before sports-memorabilia is the word prod The one after sports-memorabilia is the product id. The only one of those two used in the second method is the product id. Here is where it gets tricky. The item id stays the same in both urls but in the new style second one it actually relies on a routine in the cgi script to pull the title tag from an sql db, strip bad characters etc etc and add it to the url before it actually spits out the url. I don't know if the first one can be redirected to the second one and still have it perform that function?
RewriteRule ^cp-app/([^.]+)/sports-memorabilia/([^.]+)/?$ http://www.domain.com/sports-memorabilia-$2.html [R=301,L] If this doesn't do anything, you're toast.
Yeah. HoLY Cripes man! 7,000 rewrite rules?! Simplify! Always keep things simple, in math or real life. Good luck, you'll need it.
Does this go before the other two rules? after the other 2? In between? remove 1st rule, leave second.....???
Replace RewriteRule ^cp-app/([^/]*)/sports-memorabilia/([^/]*)/?$ shop/cgi-bin/cp-app.cgi?pg=$1&sports-memorabilia&ref=$2 [L] with that new code, and hope you're not toast!!!!