apache - .htaccess rewrites with excluded files/folders, multiple domains resolving to one host and HTTPS -
apache - .htaccess rewrites with excluded files/folders, multiple domains resolving to one host and HTTPS -
i have client atypical server setup , i'd few more eyes on code.
basically there few domains resolve same host. 1 of domains ssl , has files/folders used app. so, domainone.com needs forced www.domainone.com, ssl. then, www.domainone.com needs redirect www.domaintwo.com excluding needed files/folders.
after that, basic rules fire redirect domains have hanging around along wildcard sub-domains, excluding known sub-domains.
here latest revision of code (waiting on client test).
rewriteengine on # forces domainone traffic https (www version) rewritecond %{server_port} ^80$ rewritecond %{http_host} ^domainone.com rewriterule ^(.*)$ https://www.domainone.com/$1 [r=301,l] # redirects https traffic exceptions www.domaintwo.com rewritecond %{server_port} ^443$ rewritecond %{http_host} ^www.domainone.com rewritecond %{request_uri} !^/domaintwo/crash.ashx$ rewritecond %{request_uri} !^/domaintwo/reports/bugzscoutfallback.php$ rewritecond %{request_uri} !^/ebay/auth/token.php$ rewritecond %{request_uri} !^/account/(.*)$ rewritecond %{request_uri} !^/admin/(.*)$ rewritecond %{request_uri} !^/store/(.*)$ rewriterule ^(.*)$ http://www.domaintwo.com/$1 [r=301,l] # redirects domains , forces www domaintwo.com rewritecond %{server_port} ^80$ rewritecond %{http_host} ^www.domainthree.com [or] rewritecond %{http_host} ^domainthree.com [or] rewritecond %{http_host} ^mydomaintwo.com [or] rewritecond %{http_host} ^www.mydomaintwo.com [or] rewritecond %{http_host} ^domaintwo.com rewriterule ^(.*)$ http://www.domaintwo.com/$1 [r=301,l] # excludes known sub-domains , redirects wildcard subdomains www.domaintwo.com rewritecond %{http_host} !^support.domaintwo.com rewritecond %{http_host} !^supplies.domaintwo.com rewritecond %{http_host} !^blog.domaintwo.com rewritecond %{http_host} !^www.domaintwo.com rewritecond %{http_host} ^(.*).domaintwo.com rewriterule ^(.*)$ http://www.domaintwo.com/ [r=301,l]
i've added comments help create sense of everything. , feedback or suggestions appreciated.
this version of code threw 500 error on ssl
rewriteengine on rewritecond %{server_port} ^80$ rewritecond %{http_host} ^domainone.com [or] rewritecond %{http_host} ^www.domainone.com [or] rewritecond %{http_host} ^www.domainthree.com [or] rewritecond %{http_host} ^domainthree.com [or] rewritecond %{http_host} ^mydomaintwo.com [or] rewritecond %{http_host} ^www.mydomaintwo.com [or] rewritecond %{http_host} ^domaintwo.com rewritecond %{request_uri} !^/domaintwo/crash.ashx$ rewritecond %{request_uri} !^/domaintwo/reports/bugzscoutfallback.php$ rewritecond %{request_uri} !^/ebay/auth/token.php$ rewritecond %{request_uri} !^/account/(.*)$ rewritecond %{request_uri} !^/admin/(.*)$ rewritecond %{request_uri} !^/store/(.*)$ rewriterule ^(.*)$ http://www.domaintwo.com/$1 [r=301,l] #force www , https exceptionsite.com exceptions rewritecond %{server_port} ^80$ rewritecond %{http_host} ^domainone.com [or] rewritecond %{http_host} ^www.domainone.com rewriterule ^(.*)$ https://www.domainone.com/$1 [r=301,l] rewritecond %{server_port} ^443$ rewritecond %{http_host} ^domainone.com [or] rewritecond %{http_host} ^www.domainone.com rewritecond %{request_uri} !^/domaintwo/crash.ashx$ rewritecond %{request_uri} !^/domaintwo/reports/bugzscoutfallback.php$ rewritecond %{request_uri} !^/ebay/auth/token.php$ rewritecond %{request_uri} !^/account/(.*)$ rewritecond %{request_uri} !^/admin/(.*)$ rewritecond %{request_uri} !^/store/(.*)$ rewriterule ^(.*)$ http://www.domaintwo.com/$1 [r=301,l] rewritecond %{http_host} !^support.domaintwo.com rewritecond %{http_host} !^supplies.domaintwo.com rewritecond %{http_host} !^blog.domaintwo.com rewritecond %{http_host} !^www.domaintwo.com rewritecond %{http_host} ^(.*).domaintwo.com rewriterule ^(.*)$ http://www.domaintwo.com/ [r=301,l]
apache .htaccess redirect ssl
Comments
Post a Comment