Forum Moderators: phranque
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
RewriteEngine on
# Clean URLs [[[
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks -MultiViews -Indexes
Options +SymLinksIfOwnerMatch -MultiViews -Indexes
<IfModule mod_rewrite.c>
RewriteBase /store/
RewriteCond %{REQUEST_URI} !^/store/(payment|admin|provider|partner)/
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ dispatcher.php [L]
</IfModule>
# /Clean URLs ]]]
AuthName "/store"
AuthUserFile "/home8/domaincom/.htpasswds/public_html/passwd"
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^/?$ "http\:\/\/www\.example\.com\/store" [R=301,L]
RewriteCond %{REMOTE_ADDR} !=1.3.3.7 [edited by: phranque at 7:32 pm (utc) on Jul 10, 2013]
[edit reason] Please Use Example.com [webmasterworld.com] [/edit]
RewriteCond %{REMOTE_ADDR} !=1.3.3.7 RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ RewriteRule ^/?$ "http\:\/\/www\.domain\.com\/store" [R=301,L]
RewriteRule ^$ http://www.domain.com/store/ [R=301,L] would the [L] flag shown on the last line of my current .htaccess file cancel out any additional redirect changes I add, even if the changes were above it?
[edited by: phranque at 6:02 am (utc) on Jul 12, 2013]
RewriteCond %{REMOTE_ADDR} !=1.3.3.7 RewriteBase /store/
<snip>
RewriteRule ^(.*)$ dispatcher.php [L] RewriteRule .* /store/dispatcher.php [L] !^/store/(payment|admin|provider|partner)/ RewriteRule ^/?$ "http\:\/\/www\.example\.com\/store" [R=301,L] But would the [L] flag shown on the last line of my current .htaccess file
But not RewriteCond %{REMOTE_ADDR} !=1.3.3.7 with no anchors and unescaped periods, because this rule would match 123.3.7.anything 24.103.3.75 and a bunch of other IPs. If you're matching an exact IP, the rule has to be strictly constrained to ^1\.2\.3\.4$
'=CondPattern' (lexicographically equal) Treats the CondPattern as a plain string and compares it lexicographically to TestString. True if TestString is lexicographically equal to CondPattern (the two strings are exactly equal, character for character).
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=1.3.3.7
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^$ http\://www.domain.com/store/ [R=301,L]
# Redirect ruleset for generic webhost address
RewriteRule ^$ http\://box491.bluehost.com/store/ [R=301,L]
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=1.3.3.7
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^$ http\://www.domain.com/store/ [R=301,L]
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=1.3.3.7
RewriteRule ^$ http://www.domain.com/store/ [R=301,L] # Redirect ruleset for generic webhost address
RewriteRule ^$ http\://box491.bluehost.com/store/ [R=301,L]
phranque, when you stated "so you don't need to escape any special characters and it should be quoted." did you mean to say that it should NOT be quoted?
you should have an additional ruleset (after the store redirect ruleset) to handle the generic hostname canonicalization redirect.
# Redirect requests for non-blank, non-canonical hostnames to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]