.htaccess - Redirect non-www to www adding URL query string -


i use seo url on opencart using .htaccess, want redirect non-www url access url www. add these lines in .htaccess file:

rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] 

yes url redirected www if written wihout www before domain name, found think should not appear in url.

when go www.mydomain.com/category tried test url removing www (so became mydomain.com/category) , hit enter. url redirected www.mydomain.com/index.php?_route_=category. did not know made url become that, think url should redirect www.mydomain.com/category. have tried move position of redirection lines before , after line:

rewriterule ^([^?]*) index.php?_route_=$1 [l,qsa] 

here full .htaccess content:

rewritebase /  rewriterule ^sitemap.xml$ index.php?route=feed/google_sitemap [l] rewriterule ^googlebase.xml$ index.php?route=feed/google_base [l] rewriterule ^download/(.*) /index.php?route=error/not_found [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !.*\.(ico|gif|jpg|jpeg|png|js|css) rewriterule ^([^?]*) index.php?_route_=$1 [l,qsa]  # redirect non-www www (i have tried move lines still resulting same) rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] 

what wrong redirection lines? , suggestion appreciated. thank you.

the issue you've put rewrite domain low down. move after rewritebase / , execute before url rewrites do

rewritebase / # redirect non-www www (i have tried move lines still resulting same) rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  rewriterule ^sitemap.xml$ index.php?route=feed/google_sitemap [l] rewriterule ^googlebase.xml$ index.php?route=feed/google_base [l] rewriterule ^download/(.*) /index.php?route=error/not_found [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !.*\.(ico|gif|jpg|jpeg|png|js|css) rewriterule ^([^?]*) index.php?_route_=$1 [l,qsa] 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -