Forum Moderators: open
Please keep in mind that as soon as you install an ISAPI filter like this, the default settings from the server no longer function. You need to add rules for each of those so you can put them back to normal. ;)
[ISAPI_Rewrite] # webresource file for asp.net
RewriteRule /(webresource.axd.*) /$1 [I,L] # 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] # Exclude anything that starts with _ for frontpage extension, if enabled.
# ie, _derived, _private _vti_cnf
RewriteRule (.*/_.*) $1 [I,L] # Place any exceptions here.
# Example here showing to execute any images, css, js, as is
RewriteRule /(js¦nav¦images)/(.*) /$1/$2 [I,L]
RewriteRule (.*)(\.css¦\.js) $1$2 [I,L] # Set different robots.txt for differnt protocol
# You need to create a robots.https.txt (update this to point to the correct script)
RewriteCond %HTTPS on
RewriteRule /robots.txt /robots.https.txt [I,O,L] # Move anything from non- www.example100.com -> www.example100.com
# ie, example100.com -> www.example100.com
RewriteCond %HTTPS off
RewriteCond Host: (?!^www.example100.com)(.+)
RewriteRule /(.*) http\://www.example100.com/$2 [I,RP] # Same as above but for SSL
RewriteCond %HTTPS on
RewriteCond Host: (?!^www.example100.com)(.+)
RewriteRule /(.*) https\://www.example100.com/$2 [I,RP] # Add trailing slash for folders
RewriteRule ([^.?]+[^.?/]) http://$1$2/ [I,RP] # Convert all upper case to lower
# If you are using http post, you must make sure everything in the URI are lower case
# Otherwise the redirect will lose the form values
RewriteCond URL ([^?]+[[:upper:]][^?]*).*
RewriteHeader X-LowerCase-URI: .* $1 [CL] RewriteCond %HTTPS on
RewriteCond X-LowerCase-URI: (.+)
RewriteRule [^?]+(.*) https\://www.example100.com$1$2 [I,RP] RewriteCond %HTTPS off
RewriteCond X-LowerCase-URI: (.+)
RewriteRule [^?]+(.*) http\://www.example100.com$1$2 [I,RP] # If you have any folders/files that need to be SSL enabled, list them here.
# Redirect all the following folders to SSL if it's not SSL currently
RewriteCond %HTTPS off
RewriteRule /(client¦admin¦contact)/(.*) https://www.example100.com/$1/$2 [I,RP] # This line will execute the code since it passed all the above checks and it's still SSL.
# The matching expression should be the same as last line.
RewriteCond %HTTPS on
RewriteRule /(client¦admin¦contact)/(.*) /$1/$2 [I,L] # This will force ANY https:// to http: if they are not in the last rule above.
RewriteCond %HTTPS on
RewriteRule (.*) http://www.example.com$1 [I,RP] Again, these are "our" default rules. Yours may vary depending on your level of regex expertise and the type of dynamic environment you are developing.
For those of you working with ISAPI_Rewrite 2.0, are you doing anything by default that we've not listed above?
Could you make a detailed howto on ISAPI. I need to implement it very soon and had no idea it required so much stuff. I thought it was something you just installed and you could put some rules on it. Are you saying that if I install ISAPI on an IIS server it will hose the server until it is set up right?
Sorry ogletree, I didn't catch your reply on this one. I posted and it just dropped to the depths of WebmasterWorld. ;)
The above list of rules are those that we've developed over the years based on what Windows does and doesn't do after the ISAPI installation. There are little things here and there that you need to account for and the above rules are a solid starting point for most.
Would you recommend the same modifications for the newest version, 3.x?
I haven't really worked with 3.0 much as it uses the .htaccess method and I prefer the .ini due to my editing environment. But yes, the same ruleset would apply for both 2.0 and 3.0 although I think they will need to be slightly modified for the .htaccess file.
There are some pretty solid tutorials on the Helicon site in regards to this.
I posted and it just dropped to the depths of WebmasterWorld.
Hope that helps. ;)
Thanks for the advice on Helicon's tutorials. I always forget they provide lots of good examples on how to use their products. Plus you can always get a good answer from them in their forums. :)
You need to add a link to My Threads in the header section Brett has so kindly made available to us.
Hehehe, the "My Threads" for me reads like the front page of WebmasterWorld. If I don't look there "every day", I'm going to miss a few that rolled off the list because I didn't catch them in time.
Plus you can always get a good answer from them in their forums.
Yaroslav and his team make sure of that. You can expect an answer usually before the end of the day on most topics.