Fixes double-login problem and guarantees that htpasswd basic authorization can only be entered using HTTPS.
NOTE: You will only find this method on this site and it is the most secure way to do this.
SSLOptions +StrictRequire SSLRequireSSL SSLRequire %{HTTP_HOST} eq "askapache.com" ErrorDocument 403 https://askapache.com
NOTE:The HTTPS variable is always present,evenif mod_ssl isn't loaded! Based on HTTPS variable (best)
RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Based on SERVER_PORT
RewriteCond %{SERVER_PORT} !^443$ RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{SERVER_PORT} ^80$ RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteRule "^/normal/secure(/.*)" "https://%{HTTP_HOST}$1" [R=301,L]
Check to see whether the HTTPS environment variable is set
RewriteCond %{HTTPS} !=on RewriteRule "^(/secure/.*)" "https://%{HTTP_HOST}$1" [R=301,L]
This lets you use hyperlinks like this
/doc.html:SSL – > https://google.com/doc.html /doc.html:NOSSL –> http://google.com/doc.html
RewriteRule ^/(.*):SSL$ https://%{SERVER_NAME}/$1 [R,L] RewriteRule ^/(.*):NOSSL$ http://%{SERVER_NAME}/$1 [R,L]
# Block some known robots/crawlers on URLs where query arguments are present. # DOES allow basic URLs like /news/feed, /node/1 or /rss, etc. # BLOCKS only when search arguments are present like # /news/feed?search=XXX or /rss?page=21. # Note: You can add more conditions if needed. # For example, to only block on URLs that begin with '/search', add this # line before the RewriteRule: # RewriteCond %{REQUEST_URI} ^/search # RewriteCond %{QUERY_STRING} . RewriteCond %{HTTP_USER_AGENT} 11A465|Ahrefs|ArchiveBot|AspiegelBot|Baiduspider|bingbot|BLEXBot|Bytespider|CCBot|Curebot|Daum|Detectify|DotBot|Grapeshot|heritrix|Kinza|LieBaoFast|Linguee|LMY47V|MauiBot|Mb2345Browser|MegaIndex|MicroMessenger|MJ12bot|MQQBrowser|PageFreezer|PiplBot|Riddler|Screaming.Frog|Search365bot|Seekport|SemanticScholarBot|SemrushBot|SEOkicks|serpstatbot|Siteimprove.com|Sogou.web.spider|trendictionbot|TurnitinBot|UCBrowser|weborama-fetcher|Vagabondo|VelenPublicWebCrawler|YandexBot|YisouSpider [NC] RewriteRule ^.* - [F,L]