Simple 301 redirect in ISAPI Rewrite for windows server 2003

Posted on 2008-11-11
Last Modified: 2012-05-05
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

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!



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\://$1 [I,RP]

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

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

Question by:alexealden
    1 Comment

    Accepted Solution

    OK solved this myself ... it was as simple as moving the rule up the list so it was before the other /sitepage/ folder rule. DOH... I thought I had already tried this without success!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now