This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: New website launch,301 redirects *URGENT*
Author
Message |
jamesnoony
Newbie


Joined: 15 April 2009
Posts: 25
Posted: 01 February 2011 at 6:24am

Hi, I am about to launch a new site. The old site is also on my server and used Link Freeze.

The new site uses APE rulebase for SEO friendly URL's.

Initially I would like to add 301 redirects from OLD category URL's to new, the category structure is not too big so I dont mind entering the old and new url's manually.

IE

http://www.mysite.com/oldcategoryURL/mypage.htm
301 redirect to
http://www.mysite.com/newcategoryURL

and then loop for all pages I need redirecting.

So the initial requested URL's are what google has spidered from the old LinkFreeze site.

Please advise how I can do this, example code so I can test on a few URL's would be great.

Many Thanks. James
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 01 February 2011 at 7:03am

The 301s in Ape look like this:

RewriteEngine On
RewriteBase /
RewriteRule ^oldcategoryURL/mypage\.htm$ /newcategoryURL [NC,R=301,L]

BTW, you may find mapfiles functionality quite helpful in your situation as you can have just one generic RewriteRule which will address the
mapfile to find the corresponding destination for requested URL.

__________________
Regards,
Anton
Back to Top
 
jamesnoony
Newbie


Joined: 15 April 2009
Posts: 25
Posted: 02 February 2011 at 7:01am

Thanks, please can you provide an example using a mapfile....
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 02 February 2011 at 7:28am

Have a look at this article: http://www.helicontech.com/articles/url-rewriting-basics-and-map-files-application/
In case of any questions, please ask here.

__________________
Regards,
Anton
Back to Top
 
jamesnoony
Newbie


Joined: 15 April 2009
Posts: 25
Posted: 02 February 2011 at 7:58am

Thanks, but thats a slightly different approach to what I need.

I am moving a site (on the same server) from the old structure and so many old urls, to a new structure with new urls.

Example.. how would I program this with the txt and .htaccess.

OLD URL /category.asp/catID/4/pregnancy-and-birth.htm
NEW URL /Pregnancy-and-Birth

So I would have those two in separate columns in the map file yes?

The NEW URL's have already been re-written by ape, so I am requesting a URL that no longer exists, but I want the map file to be used to look for that request, and 301 redirect to the new url

Thanks, J
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 02 February 2011 at 8:15am

That's a classical approach to the case you have.
You need a mapfile.txt:

/category.asp/catID/4/pregnancy-and-birth.htm /Pregnancy-and-Birth
etc.

And the .htaccess:

RewriteMap map txt:mapfile.txt [NC]
RewriteCond %{REQUEST_URI} ^(.+)$ [NC]
RewriteRule .? ${map:%1} [NC,R=301,L]

__________________
Regards,
Anton
Back to Top
 
jamesnoon
Groupie


Joined: 07 December 2005
Location: United Kingdom
Posts: 79
Posted: 02 February 2011 at 8:54am

Ok that rule worked but it now conflicts with the rest of the site and I get a redirect loop error in firefox, heres the full code in my .htaccess file. The last is the category rewrite rule......

# Helicon Ape version 3.0.0.52

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.78

RewriteEngine on
RewriteBase /


DBDriver mssql
DBDParams "Data Source=.;Initial Catalog=EYM;User ID=express2010sql;Password=carlsharpass"
#Categories and products
DBDPrepareSQL "SELECT T.CategoryPage FROM [dbo].[tblCategoryTree] AS C INNER JOIN [dbo].[tblCategoryTransl] AS T ON C.PK_catID = T.FK_catID WHERE C.isPublic = 1 AND T.FK_languageID = 1 AND T.Translated = 1 AND T.FK_catID = @KEY" dbCategoryAndProducts
DBDPrepareSQL "SELECT CAST(T.FK_catID as nvarchar(32)) as CatID FROM [dbo].[tblCategoryTree] AS C INNER JOIN [dbo].[tblCategoryTransl] AS T ON C.PK_catID = T.FK_catID WHERE C.isPublic = 1 AND T.Translated = 1 AND T.CategoryPage = @KEY" dbCategoryAndProductsRev
#Categories
DBDPrepareSQL "SELECT T.CategoryPage FROM [dbo].[tblCategoryTree] AS C INNER JOIN [dbo].[tblCategoryTransl] AS T ON C.PK_catID = T.FK_catID WHERE C.isPublic = 1 AND C.DisplayType = 1 AND T.FK_languageID = 1 AND T.Translated = 1 AND T.FK_catID = @KEY" dbCategory
DBDPrepareSQL "SELECT CAST(T.FK_catID as nvarchar(32)) as CatID FROM [dbo].[tblCategoryTree] AS C INNER JOIN [dbo].[tblCategoryTransl] AS T ON C.PK_catID = T.FK_catID WHERE C.isPublic = 1 AND C.DisplayType = 1 AND T.Translated = 1 AND T.CategoryPage = @KEY" dbCategoryRev
#Products
DBDPrepareSQL "SELECT T.CategoryPage FROM [dbo].[tblCategoryTree] AS C INNER JOIN [dbo].[tblCategoryTransl] AS T ON C.PK_catID = T.FK_catID WHERE C.isPublic = 1 AND C.DisplayType = 2 AND T.FK_languageID = 1 AND T.Translated = 1 AND T.FK_catID = @KEY" dbProducts
DBDPrepareSQL "SELECT CAST(T.FK_catID as nvarchar(32)) as CatID FROM [dbo].[tblCategoryTree] AS C INNER JOIN [dbo].[tblCategoryTransl] AS T ON C.PK_catID = T.FK_catID WHERE C.isPublic = 1 AND C.DisplayType = 2 AND T.Translated = 1 AND T.CategoryPage = @KEY" dbProductsRev
DBDPrepareSQL "SELECT CAST(T.FK_catID as nvarchar(32)) as CatID FROM [dbo].[tblCategoryTree] AS C INNER JOIN [dbo].[tblCategoryTransl] AS T ON C.PK_catID = T.FK_catID WHERE C.isPublic = 1 AND T.Translated = 1 AND T.CategoryPage = @KEY" dbProductsBrandsRev
#Content
DBDPrepareSQL "SELECT T.pageFileName FROM [dbo].[tblWebContentTitle] AS C INNER JOIN [dbo].[tblWebContentTransl] AS T ON C.PK_contentID = T.FK_contentID WHERE T.FK_languageID = 1 AND T.Translated = 1 AND T.FK_contentID = @KEY" dbContent
DBDPrepareSQL "SELECT CAST(T.FK_contentID as nvarchar(32)) as ContentID FROM [dbo].[tblWebContentTitle] AS C INNER JOIN [dbo].[tblWebContentTransl] AS T ON C.PK_contentID = T.FK_contentID WHERE T.Translated = 1 AND T.pageFileName = @KEY" dbContentRev
#Brands
DBDPrepareSQL "SELECT C.URLkey FROM [dbo].[tblBrands] AS C WHERE C.[Browsable] = 1 AND C.PK_showBrandID = @KEY" dbBrands
DBDPrepareSQL "SELECT CAST(C.PK_showBrandID as nvarchar(32)) as PK_showBrandID FROM [dbo].[tblBrands] AS C WHERE C.[Browsable] = 1 AND C.URLkey = @KEY" dbBrandsRev

#Details 1
DBDPrepareSQL "SELECT C.PageFileName FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 1 AND C.[ProductID] = @KEY" dbDetails1
DBDPrepareSQL "SELECT CAST(C.ProductID as nvarchar(32)) as ProductID FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 1 AND C.PageFileName = @KEY" dbDetails1Rev
#Details 2
DBDPrepareSQL "SELECT C.PageFileName FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 2 AND C.[ProductID] = @KEY" dbDetails2
DBDPrepareSQL "SELECT CAST(C.ProductID as nvarchar(32)) as ProductID FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 2 AND C.PageFileName = @KEY" dbDetails2Rev
#Details 3
DBDPrepareSQL "SELECT C.PageFileName FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 3 AND C.[ProductID] = @KEY" dbDetails3
DBDPrepareSQL "SELECT CAST(C.ProductID as nvarchar(32)) as ProductID FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 3 AND C.PageFileName = @KEY" dbDetails3Rev
#Details 4
DBDPrepareSQL "SELECT C.PageFileName FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 4 AND C.[ProductID] = @KEY" dbDetails4
DBDPrepareSQL "SELECT CAST(C.ProductID as nvarchar(32)) as ProductID FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 4 AND C.PageFileName = @KEY" dbDetails4Rev
#Details 5
DBDPrepareSQL "SELECT C.PageFileName FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 5 AND C.[ProductID] = @KEY" dbDetails5
DBDPrepareSQL "SELECT CAST(C.ProductID as nvarchar(32)) as ProductID FROM [dbo].[tblProducts] AS C WHERE ISNULL(C.[Discontinued], 0) = 0 AND C.[ProcessType] = 5 AND C.PageFileName = @KEY" dbDetails5Rev

RewriteMap catAndProd-mapfile dbd:dbCategoryAndProducts [NC]
RewriteMap catAndProd-revmapfile dbd:dbCategoryAndProductsRev [NC]
### DETAILS 1 ###
RewriteMap details1-mapfile dbd:dbDetails1 [NC]
RewriteMap details1-revmapfile dbd:dbDetails1Rev [NC]

RewriteCond %{REQUEST_FILENAME} details1\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&sid=(\d+)$ [NC]
RewriteCond ${details1-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteCond ${catAndProd-mapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteRule .* /%4/%3? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} details1\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&*(.*?)$ [NC]
RewriteCond ${details1-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule .* /%3\?%2? [NC,R=301,L]

RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details1-revmapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteCond ${catAndProd-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %5 !NOT_FOUND
RewriteRule ^(.+)$ /details1.asp?id=%4&sid=%5&%3 [NC,L,NS]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)$ [NC]
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details1-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule ^(.+)$ /details1.asp?id=%3&%2 [NC,L,NS]

### DETAILS 2 ###
RewriteMap details2-mapfile dbd:dbDetails2 [NC]
RewriteMap details2-revmapfile dbd:dbDetails2Rev [NC]

RewriteCond %{REQUEST_FILENAME} details2\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&sid=(\d+)$ [NC]
RewriteCond ${details2-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteCond ${catAndProd-mapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteRule .* /%4/%3? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} details2\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&*(.*?)$ [NC]
RewriteCond ${details2-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule .* /%3\?%2? [NC,R=301,L]

RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details2-revmapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteCond ${catAndProd-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %5 !NOT_FOUND
RewriteRule ^(.+)$ /details2.asp?id=%4&sid=%5&%3 [NC,L,NS]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)$ [NC]
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details2-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule ^(.+)$ /details2.asp?id=%3&%2 [NC,L,NS]

### DETAILS 3 ###
RewriteMap details3-mapfile dbd:dbDetails3 [NC]
RewriteMap details3-revmapfile dbd:dbDetails3Rev [NC]

RewriteCond %{REQUEST_FILENAME} details3\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&sid=(\d+)$ [NC]
RewriteCond ${details3-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteCond ${catAndProd-mapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteRule .* /%4/%3? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} details3\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&*(.*?)$ [NC]
RewriteCond ${details3-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule .* /%3\?%2? [NC,R=301,L]

RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details3-revmapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteCond ${catAndProd-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %5 !NOT_FOUND
RewriteRule ^(.+)$ /details3.asp?id=%4&sid=%5&%3 [NC,L,NS]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)$ [NC]
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details3-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule ^(.+)$ /details3.asp?id=%3&%2 [NC,L,NS]

### DETAILS 4 ###
RewriteMap details4-mapfile dbd:dbDetails4 [NC]
RewriteMap details4-revmapfile dbd:dbDetails4Rev [NC]

RewriteCond %{REQUEST_FILENAME} details4\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&sid=(\d+)$ [NC]
RewriteCond ${details4-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteCond ${catAndProd-mapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteRule .* /%4/%3? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} details4\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&*(.*?)$ [NC]
RewriteCond ${details4-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule .* /%3\?%2? [NC,R=301,L]

RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details4-revmapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteCond ${catAndProd-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %5 !NOT_FOUND
RewriteRule ^(.+)$ /details4.asp?id=%4&sid=%5&%3 [NC,L,NS]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)$ [NC]
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details4-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule ^(.+)$ /details4.asp?id=%3&%2 [NC,L,NS]

### DETAILS 5 ###
RewriteMap details5-mapfile dbd:dbDetails5 [NC]
RewriteMap details5-revmapfile dbd:dbDetails5Rev [NC]

RewriteCond %{REQUEST_FILENAME} details5\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&sid=(\d+)$ [NC]
RewriteCond ${details5-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteCond ${catAndProd-mapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteRule .* /%4/%3? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} details5\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)&*(.*?)$ [NC]
RewriteCond ${details5-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule .* /%3\?%2? [NC,R=301,L]

RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details5-revmapfile:%2|NOT_FOUND} (.*)
RewriteCond %4 !NOT_FOUND
RewriteCond ${catAndProd-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %5 !NOT_FOUND
RewriteRule ^(.+)$ /details5.asp?id=%4&sid=%5&%3 [NC,L,NS]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)$ [NC]
RewriteCond %{QUERY_STRING} ^(.*)$ [NC]
RewriteCond ${details5-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule ^(.+)$ /details5.asp?id=%3&%2 [NC,L,NS]

### Categories ###
#to use relative paths in RewriteMap, map files must reside in the same folder as .htaccess
RewriteMap cat-mapfile dbd:dbCategory [NC]
RewriteMap cat-revmapfile dbd:dbCategoryRev [NC]

# Redirect: /category.asp?id=3 => /banjos
RewriteCond %{REQUEST_FILENAME} category\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)$ [NC]
RewriteCond ${cat-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %2 !NOT_FOUND
RewriteRule ^category\.asp$ /%2? [NC,R=301,L]

# Getting content from /category.asp?id=3 when requesting /banjos
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${cat-revmapfile:$1|NOT_FOUND} (.*)
RewriteCond %1 !NOT_FOUND
RewriteRule ^(.+)$ /category.asp?id=%1 [NC,L,NS]

### Products ###
RewriteMap product-mapfile dbd:dbProducts [NC]
RewriteMap product-revmapfile dbd:dbProductsRev [NC]
RewriteMap productBrands-revmapfile dbd:dbProductsBrandsRev [NC]

RewriteCond %{REQUEST_FILENAME} products\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)$ [NC]
RewriteCond ${product-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %2 !NOT_FOUND
RewriteRule ^products\.asp$ /%2? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${product-revmapfile:$1|NOT_FOUND} (.*)
RewriteCond %1 !NOT_FOUND
RewriteRule ^(.+)$ /products.asp?id=%1 [NC,L,NS]

#THIS RULE MUST BE AFTER ALL DETAILS RULE
# Getting content from /products.asp?id=3 when requesting /banjos/Adidas
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${productBrands-revmapfile:%1|NOT_FOUND} (.*)
RewriteCond %3 !NOT_FOUND
RewriteRule ^(.+)$ /products.asp?id=%3&BrandName=%2 [NC,L,NS]

### Content ###
#to use relative paths in RewriteMap, map files must reside in the same folder as .htaccess
RewriteMap cnt-mapfile dbd:dbContent [NC]
RewriteMap cnt-revmapfile dbd:dbContentRev [NC]

# Redirect: /category.asp?id=3 => /banjos
RewriteCond %{REQUEST_FILENAME} content\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^id=(\d+)$ [NC]
RewriteCond ${cnt-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %2 !NOT_FOUND
RewriteRule ^content\.asp$ /%2? [NC,R=301,L]

# Getting content from /category.asp?id=3 when requesting /banjos
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${cnt-revmapfile:$1|NOT_FOUND} (.*)
RewriteCond %1 !NOT_FOUND
RewriteRule ^(.+)$ /content.asp?id=%1 [NC,L,NS]

### Brands ###
#to use relative paths in RewriteMap, map files must reside in the same folder as .htaccess
RewriteMap brnds-mapfile dbd:dbBrands [NC]
RewriteMap brnds-revmapfile dbd:dbBrandsRev [NC]

# Redirect: /brand.asp?BrandID=3 => /banjos
RewriteCond %{REQUEST_FILENAME} brand\.asp$ [NC]
RewriteCond %{QUERY_STRING} ^BrandID=(\d+)$ [NC]
RewriteCond ${brnds-mapfile:%1|NOT_FOUND} (.*)
RewriteCond %2 !NOT_FOUND
RewriteRule ^brand\.asp$ /%2? [NC,R=301,L]

# Getting content from /brand.asp?BrandID=3 when requesting /banjos
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${brnds-revmapfile:$1|NOT_FOUND} (.*)
RewriteCond %1 !NOT_FOUND
RewriteRule ^(.+)$ /brand.asp?BrandID=%1 [NC,L,NS]

# Rewrite old category urls
RewriteMap map txt:CatMap.txt [NC]
RewriteCond %{REQUEST_URI} ^(.+)$ [NC]
RewriteRule .? ${map:%1} [NC,R=301,L]
Back to Top Visit jamesnoon's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 02 February 2011 at 9:09am

Ok, I can suggest you a fix to the rule in question that will check if the requested URL exists in the map, then the rule will fire, otherwise
it won't:

# Rewrite old category urls
RewriteMap map txt:CatMap.txt [NC]
RewriteCond %{REQUEST_URI} ^(.+)$ [NC]
RewriteCond ${map:%1|NOT_FOUND} !NOT_FOUND
RewriteRule .? ${map:%1} [NC,R=301,L]

__________________
Regards,
Anton
Back to Top
 
jamesnoon
Groupie


Joined: 07 December 2005
Location: United Kingdom
Posts: 79
Posted: 02 February 2011 at 10:26am

That works great, many thanks, J
Back to Top Visit jamesnoon's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version