Forum Moderators: phranque
I found a code which redirect non www.
<snip>
Options +Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
There is a problem. As you see in the code, it specify on example.com only. But I use 1 wordpress to manage a lot of sites. So it's impossible for me to state 1 domain or all domains.
Is it possible not to specify on any domain and domain extensions (i might use .com .net or .org)?
Thanks.
[edited by: jdMorgan at 2:16 pm (utc) on July 29, 2007]
[edit reason] No URLs, please. See TOS. [/edit]
If you want the first option, then just add another two-line rule to the configuration for each domain to be redirected.
If you want to redirect all of them to .com then the fist line should be:
RewriteCond %{HTTP_HOST} !^www\.example\.com
OR, more long-winded, a rule for:
RewriteCond %{HTTP_HOST} ^example\.(com她rg好et在iz)
and another for:
RewriteCond %{HTTP_HOST} ^www\.example\.(org好et在iz)
That's about all it takes -- You can use the server variables in the substitution URL.
Jim