php - htaccess redirect TLD preserve subdomains -


i want redirect tlds specific tld, , want preserve subdomains.

the followings redirect examples need:

sub1.domain.net -> sub1.domain.com sub2.domain.net -> sub2.domain.com sub3.domain.net -> sub3.domain.com  sub1.domain.org -> sub1.domain.com sub2.domain.org -> sub2.domain.com sub3.domain.org -> sub3.domain.com 

i have tried code in .htacess file:

rewritecond %{http_host} !^([a-za-z_\-\.(0-9)]*)domain\.com rewriterule  ^ http://$1domain.com%{request_uri} [l,r=301] 

but $1 not recognized variable.

$1 undefined in example not capturing uri. use captured part of hostaname ,you need %n variable. :

rewritecond %{http_host} !example\.com$ rewritecond %{http_host} ^((?!www\.).+)\..+$ rewriterule ^ http://%1.example.com%{request_uri} [ne,l,r] 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -