Link to home
Start Free TrialLog in
Avatar of alexealden
alexealden

asked on

Simple 301 redirect in ISAPI Rewrite for windows server 2003

Hi Experts,

I hope you can help, I am ttrying to sort out a simple 301 redirecty rule using ISAPI Rewrite... I am  finding it much harder rthan I would have thought. I have tried adapting a number of rules that I have found onlien but no luck.

I am basically just trying to create  permanant 301 redirect from www.mysite.com/sitepage/scrapbook_photo_albums.html
to
www.mysite.com/pcp/scrapbook_photo_albums.html

I think the problem is that I have a rule that already deals with the /sitepage/ folder and may be interupting I have posted my rule list in the hope that someone can help with this!

Thanks!


[ISAPI_Rewrite]

RepeatLimit 32

# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [F,I,O]

# Block external access to the Helper ISAPI Extension
RewriteRule .*\.isrwhlp / [F,I,O]

# This takes all references to images/xxxx.gif, deletes any preceding folders and rewrites the URL as /images/xxxx.gif
# Except for where /merchantadmin/images/xxxx.gif appears.  In this case it keeps it as /merchantadmin/images/xxxx.gif - this is all to
# enable relative paths to work
RewriteRule ((.*/merchantadmin)|(.*/secure)|(?:.*?))(/images/.*) (?2/merchantadmin:)(?3/secure:)$4 [I]

#Makes sure all nested references to the files below get shifted up to the root.
RewriteRule .*?(main.asp.*?) /$1 [I]
RewriteRule .*?(products.asp.*?) /$1 [I]
RewriteRule .*?(custreg.asp.*?) /$1 [I]
RewriteRule .*?(compare.asp.*?) /$1 [I]
RewriteRule .*?(viewcart.asp.*?) /$1 [I]
RewriteRule .*?(search.asp[^x].*?) /$1 [I]
RewriteRule .*?(code/addtoorder.asp.*?) /$1 [I]
RewriteRule .*?(code/addtoordermultiple.asp.*?) /$1 [I]
RewriteRule .*?(code/addtoorderspecial.asp.*?) /$1 [I]
RewriteRule .*?(code/reorder.asp.*?) /$1 [I]
RewriteRule .*?(code/cancel.asp.*?) /$1 [I]
RewriteRule .*?(code/quote.asp.*?) /$1 [I]

# translates /mcp/categoryname.html into main.asp?category=categoryname
RewriteRule /mcp/(.*?)\.html? /main.asp\?category=$1 [I]

# translates /pcp/categoryname.html into products.asp?category=categoryname
# also /pcp:tid4:/categoryname.html into into products.asp?category=categoryname&templateid=4
# also /page8/pcp:tid4:/categoryname.html into into products.asp?category=categoryname&templateid=4&abspage=8
RewriteRule ((?:/page(\d+))|(?:.*?))/pcp((?::tid(\d+):)|(?:.*?))/(.*?)\.html? /products.asp\?category=$5(?4&templateid=$4:)(?2&abspage=$2:) [I]

# translates /scp/categoryname/subcategoryname.html into products.asp?category=categoryname&subcategory=subcategoryname  
# also /scp:tid4:/categoryname/subcategoryname.html into into products.asp?category=categoryname&subcategory=subcategoryname&templateid=4
# also /page8/scp:tid4:/categoryname/subcategoryname.html into into products.asp?category=categoryname&subcategory=subcategoryname&templateid=4&abspage=8
RewriteRule ((?:/page(\d+))|(?:.*?))/scp((?::tid(\d+):)|(?:.*?))/(.*?)/(.*?)\.html? /products.asp\?category=$5&subcategory=$6(?4&templateid=$4:)(?2&abspage=$2:) [I]

# translates /pp/categoryname/subcategoryname/productname.html into products.asp?category=categoryname&subcategory=subcategoryname&product=productname.html
# translates /pp/categoryname/productname.html into products.asp?category=categoryname&product=productname.html
RewriteRule /pp((?::tid(\d+):)|(?:.*?))/(.*?)/(?:(.*?)/)?(.*?)\.html? /products.asp\?category=$3(?4&subcategory=$4)&product=$5(?2&templateid=$2:) [I]

# This rule substitutes /sp/category/clothes/subcategory/shirts/templateid/23/searchbox1/lonsdale.html into /search.asp?category=clothes&subcategory=shirts&searchbox1=lonsdale@templateid=23
RewriteRule /(?:sp|search\.asp)([^/]+)?/([^/]*)?/([^/]*)?(.+?)? /search.asp(?1$1&:\?)$2=$3(?4$4) [N,I]

# translates /sitepage/sitepagename.html into main.asp?sitepages=sitepagename
RewriteRule /sitepage/(.*?)\.html? /main.asp\?sitepages=$1 [I]

# redirect to www
RewriteCond Host: (?:mysite|mysite)\.(?:co\.uk|com)
RewriteRule (.*) http\://www.mysite.com$1 [I,RP]


# redirect main.asp to site root
RewriteCond Host: www\.mysite\.com
RewriteRule /main\.asp http\://www.mysite.com/ [I,RP]

# redirect old site pages to /pcp/ equvilant
RewriteRule http\://www.mysite.com/sitepage/scrapbook_albums\.html http\://www.mysite.com/pcp/scrapbook_albums.html [I,RP]

ASKER CERTIFIED SOLUTION
Avatar of alexealden
alexealden

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial