Forum Moderators: phranque
& then whenever someone types in example-A.com they land on example-B.com.
Beyond blocking bad ip's and the above trick, I really don't know much about .htaccess.
This is the code I found:
RewriteEngine on
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.originalsite.net
AuthUserFile /home/originalsite/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/originalsite/public_html/_vti_pvt/service.grp
# disable directory browsing
Options All -Indexes
AddType application/x-httpd-php .html .htm .inc
AddHandler application/x-httpd-php .html .htm .incRewriteCond %{HTTP_HOST} ^originalsite.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.originalsite.net$
RewriteRule ^/?$ "http\:\/\/www\.newsitename\.com" [R=301,L]
I did a bit of research & just want to know where I should put my redirect into this configuration.
+ what is going on at the bottom code? It looks like the original webdesigner tried to do a redirect -> which doesn't work. There are currently 2 sites with duplicate content, not a good thing.
RewriteCond %{HTTP_HOST} ^originalsite[b]\.[/b]net$ [OR]
RewriteCond %{HTTP_HOST} ^www[b]\.[/b]originalsite[b]\.[/b]net$ but I would just do:
RewriteCond %{HTTP_HOST} [b]![/b]^www[b]\.[/b]newsitename[b]\.[/b]net$ There is way too much wrong with this line:
RewriteRule ^/?$ "http\:\/\/www\.newsitename\.com" [R=301,L] should only be
RewriteRule [i]<pattern>[/i] http[b]://[/b]www[b].[/b]newsitename[b].[/b]com [R=301,L] The
^/?$ pattern is also odd. It only forwards for root '/' requests, not for any requested folders or sub-pages. Additionally, you need ^$ if the code is in .htaccess and ^/$ if the code is in httpd.conf. I would use
(.*) for <pattern>, and that's one of the rare occasions when using (.*) is the right thing to do (often it is the most inefficient pattern to use).
1. Is the following correct? I only changed the bottom following your suggestions & the apache.org mod_rewrite pg.
2. I'm still confused on the indexignore. I get that it's saying to look at htaccess first, but what is the rest? & am I correct in seeing the header & readme is commented (if you saw the cpanel dir files you'd be horrified at how sloppy they are, still cleaning house)
Thank you again!
RewriteEngine on
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.originalsite.net
AuthUserFile /home/originalsite/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/originalsite/public_html/_vti_pvt/service.grp
# disable directory browsing
Options All -Indexes
AddType application/x-httpd-php .html .htm .inc
AddHandler application/x-httpd-php .html .htm .inc
# redirect old site to new site
RewriteRule (.*) [newsitename.com...] [R=301,L]
# always use www version
rewritecond %{http_host} ^newsitename.com [nc]
rewriterule ^(.*)$ [newsitename.com...] [r=301,L]
# Externally redirect old site to new site (on a different
# server or in a separate filespace on this server)
RewriteRule ^(.*)$ http://www.newsitename.com/$1 [R=301,L]
# Externally redirect old site to new site (in this same server filespace)
RewriteCond %{HTTP_HOST} !^(www\.newsitename\.com)?$
RewriteRule ^(.*)$ http://www.newsitename.com/$1 [R=301,L]
You could also shorten the entire mod_access section to:
Order Deny,Allow
#
<LimitExcept GET POST>
Deny from all
</LimitExcept>
It is neither necessary (nor in most cases desirable) to use "Allow from all" since that will preclude using subsequent Denys to control access by IP address, user-agent, requested URI, etc. See Apache mod_access for details.
Jim