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\.er rors).* / [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)|(.*/se cure)|(?:. *?))(/imag es/.*) (?2/merchantadmin:)(?3/sec ure:)$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/addtoordermultipl e.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=category name
RewriteRule /mcp/(.*?)\.html? /main.asp\?category=$1 [I]
# translates /pcp/categoryname.html into products.asp?category=cate goryname
# also /pcp:tid4:/categoryname.ht ml into into products.asp?category=cate goryname&t emplateid= 4
# also /page8/pcp:tid4:/categoryn ame.html into into products.asp?category=cate goryname&t emplateid= 4&abspage= 8
RewriteRule ((?:/page(\d+))|(?:.*?))/p cp((?::tid (\d+):)|(? :.*?))/(.* ?)\.html? /products.asp\?category=$5 (?4&templa teid=$4:)( ?2&abspage =$2:) [I]
# translates /scp/categoryname/subcateg oryname.ht ml into products.asp?category=cate goryname&s ubcategory =subcatego ryname
# also /scp:tid4:/categoryname/su bcategoryn ame.html into into products.asp?category=cate goryname&s ubcategory =subcatego ryname&tem plateid=4
# also /page8/scp:tid4:/categoryn ame/subcat egoryname. html into into products.asp?category=cate goryname&s ubcategory =subcatego ryname&tem plateid=4& abspage=8
RewriteRule ((?:/page(\d+))|(?:.*?))/s cp((?::tid (\d+):)|(? :.*?))/(.* ?)/(.*?)\. html? /products.asp\?category=$5 &subcatego ry=$6(?4&t emplateid= $4:)(?2&ab spage=$2:) [I]
# translates /pp/categoryname/subcatego ryname/pro ductname.h tml into products.asp?category=cate goryname&s ubcategory =subcatego ryname&pro duct=produ ctname.htm l
# translates /pp/categoryname/productna me.html into products.asp?category=cate goryname&p roduct=pro ductname.h tml
RewriteRule /pp((?::tid(\d+):)|(?:.*?) )/(.*?)/(? :(.*?)/)?( .*?)\.html ? /products.asp\?category=$3 (?4&subcat egory=$4)& product=$5 (?2&templa teid=$2:) [I]
# This rule substitutes /sp/category/clothes/subca tegory/shi rts/templa teid/23/se archbox1/l onsdale.ht ml into /search.asp?category=cloth es&subcate gory=shirt s&searchbo x1=lonsdal e@template id=23
RewriteRule /(?:sp|search\.asp)([^/]+) ?/([^/]*)? /([^/]*)?( .+?)? /search.asp(?1$1&:\?)$2=$3 (?4$4) [N,I]
# translates /sitepage/sitepagename.htm l into main.asp?sitepages=sitepag ename
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]
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\.er
# 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
# enable relative paths to work
RewriteRule ((.*/merchantadmin)|(.*/se
#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.*?
RewriteRule .*?(code/addtoordermultipl
RewriteRule .*?(code/addtoorderspecial
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=category
RewriteRule /mcp/(.*?)\.html? /main.asp\?category=$1 [I]
# translates /pcp/categoryname.html into products.asp?category=cate
# also /pcp:tid4:/categoryname.ht
# also /page8/pcp:tid4:/categoryn
RewriteRule ((?:/page(\d+))|(?:.*?))/p
# translates /scp/categoryname/subcateg
# also /scp:tid4:/categoryname/su
# also /page8/scp:tid4:/categoryn
RewriteRule ((?:/page(\d+))|(?:.*?))/s
# translates /pp/categoryname/subcatego
# translates /pp/categoryname/productna
RewriteRule /pp((?::tid(\d+):)|(?:.*?)
# This rule substitutes /sp/category/clothes/subca
RewriteRule /(?:sp|search\.asp)([^/]+)
# translates /sitepage/sitepagename.htm
RewriteRule /sitepage/(.*?)\.html? /main.asp\?sitepages=$1 [I]
# redirect to www
RewriteCond Host: (?:mysite|mysite)\.(?:co\.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.