Forum Moderators: phranque
I was wondering which of these is the best to use?
What is the difference between the $0 and $1 although both work okay?
Example One:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ [whateverdomain.com...] [L,R=301]
Note the $0 after the .com
Example Two:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ [whateverdomain.com...] [L,R=301]
Note the $1 after the .com
Example Three:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^whateverdomain\.com$ [NC]
RewriteRule ^(.*)$ [whateverdomain.com...] [R=301,L]
for example, if the pattern was:
^prefix(.*)$
then you might get the following results:
$1 = "foo"
$0 = "prefixfoo"
in your pattern, $1 = $0
i would use the following:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
otherwise you won't solve the junk.example.com or www.junk.example.com problems.