Forum Moderators: phranque
# Point Non WWW to WWW
RewriteCond %{HTTP_HOST} ^website.com
RewriteRule (.*) http://www.website.com/$1 [R=301,L]
# Secure Folder Http to Https
RewriteCond %{SERVER_PORT} !443$
RewriteRule ^/?(apply/.*) https://www.website.com/$1 [R=301,L] # Secure Folder http or non-www to https and www
RewriteCond %{SERVER_PORT} !443$ [OR]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(apply/.*) https://www.website.com/$1 [R=301,L]
# Rest of Site https or non-www to http and www
RewriteCond %{REQUEST_URI} !^/apply
RewriteCond %{SERVER_PORT} 443$ [OR]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L] [edited by: imbckagn at 7:45 pm (utc) on Mar 7, 2011]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
# Secure Folder http or non-www to https and www
RewriteCond %{SERVER_PORT} !443$ [OR]
RewriteCond %{HTTP_HOST} !^(www\.WEBSITE\.com)?$
RewriteRule ^(apply/.*) https://www.WEBSITE.com/$1 [R=301,L]
# Rest of Site https or non-www to http and www
RewriteCond %{REQUEST_URI} !^/apply
RewriteCond %{SERVER_PORT} 443$ [OR]
RewriteCond %{HTTP_HOST} !^(www\.WEBSITE\.com)?$
RewriteRule (.*) http://www.WEBSITE.com/$1 [R=301,L]
# Point IP to Domain
rewritecond %{http_host} ^IP ADDRESS HERE [nc]
rewriterule ^(.*)$ http://www.WEBSITE.com/$1 [r=301,nc]
# End Point IP to Domain
# iPhone Home Page Redirect
redirect 301 "/redirect-to-application/"
https://www.WEBSITE.com/apply/
# iPhone Home Page Redirect
# Deny IP Address
deny from 74.220.207.159
# End Deny IP Address
# BEGIN Deflate
<ifmodule mod_deflate.c>
<filesmatch "\.(js|css|png|jpg|gif|jpeg|htm|html|php)">
SetOutputFilter DEFLATE
</filesmatch>
</ifmodule>
# END Deflate
# Caching for One Year
<FilesMatch "\.(flv|gif|jpeg|png|ico|swf)$">
Header set Cache-Control: "max-age=29030400"
</FilesMatch>
# End Image Caching
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# iPhone Home Page Redirect
redirect 301 "/redirect-to-application/" [example.com...]
The above code should be:# iPhone Home Page Redirect
RewriteRule ^redirect-to-application https://www.example.com/apply/ [R=301,L]
and this code should be first in the .htaccess file.
# Point IP to Domain
rewritecond %{http_host} ^75.125.132.51 [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
The above code should be:# Point IP to Domain
RewriteCond %{HTTP_HOST} ^75\.125\.132\.51
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
but in fact it isn't needed as the other two redirects already fix all requests that are not for exactly www.example.com.
Use "Live HTTP Headers" for Firefox to see the HTTP transaction between browser and server. It might give some clues.
# Rest of Site https or non-www to http and www
RewriteCond %{REQUEST_URI} !^/apply
RewriteCond %{SERVER_PORT} 443$ [OR]
RewriteCond %{HTTP_HOST} !^(www\.WEBSITE\.com)?$
RewriteRule (.*) http://www.WEBSITE.com/$1 [R=301,L]
Make sure that links to images and scripts begin with a leading slash and do NOT contain protocol or domain information. This avoids the "mixed security" warning pop-up on the users browser.
Make sure that internal links to pages DO contain protocol and domain information so that clicking internal links does NOT result in a redirect.
http://www.website.com/ protocol except for the URL's I manually placed. Is there a way to control these?
<Files 403.shtml>
order allow,deny
allow from all
</Files>
# Secure Folder http or non-www to https and www
RewriteCond %{SERVER_PORT} !443$ [OR]
RewriteCond %{HTTP_HOST} !^(www\.WEBSITE\.com)?$
RewriteRule ^(apply/.*) https://www.WEBSITE.com/$1 [R=301,L]
# Secure Folder http or non-www to https and www
# Rest of Site https or non-www to http and www
RewriteCond %{REQUEST_URI} !^/(apply|wp-content|wp-includes|index\.php)
RewriteCond %{SERVER_PORT} 443$ [OR]
RewriteCond %{HTTP_HOST} !^(www\.WEBSITE\.com)?$
RewriteRule (.*) http://www.WEBSITE.com/$1 [R=301,L]
# Rest of Site https or non-www to http and www
# Deny IP Address
deny from 74.220.207.159
# End Deny IP Address
# BEGIN Deflate
<ifmodule mod_deflate.c>
<filesmatch "\.(js|css|png|jpg|gif|jpeg|htm|html|php)">
SetOutputFilter DEFLATE
</filesmatch>
</ifmodule>
# END Deflate
# Caching for One Week
<FilesMatch "\.(flv|gif|jpeg|png|ico|swf)$">
Header set Cache-Control: "max-age=16934400"
</FilesMatch>
# End Image Caching
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{SERVER_PORT} =443 [OR] RewriteCond %{SERVER_PORT} !=443 [OR]