.htaccess - apache rewrite - remove www and keep path -


i have website operates in 2 urls:

http://sub.domain.com/ 

and

http://www.sub.domain.com/ 

i unify url , use version without www. google has links versions www linking specific article (the url of path). example:

http://www.sub.domain.com/folder/some.html 

i want redirect visitors remove www prefix address , keep path article. using example above rewrite url to:

http://sub.domain.com/folder/some.html 

let's clarify:

i want:

http://www.sub.domain.com -> http://sub.domain.com 

and

http://www.sub.domain.com/folder/some.html -> http://sub.domain.com/folder/some.html 

after apply rules:

rewriteengine on  rewritecond %{http_host} ^www\.sub\.domain\.com$ [nc] rewriterule ^(.*)$ http://sub.domain.com/$1 [r=301,l] 

i get:

http://www.sub.domain.com -> http://sub.domain.com 

^^ works fine :)

and

http://www.sub.domain.com/folder/some.html -> http://sub.domain.com 

^^ works wrong :(

my other current htaccess rules: http://pastebin.com/c74u7mgl

add .htaccess in web root / directory

rewriteengine on  rewritecond %{http_host} ^www\.sub\.domain\.com$ [nc] rewriterule ^(.*)$ http://sub.domain.com/$1 [r=301,l] 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -