I have a blog, internetbusinessdaily.net, and I have the preferred domain set to without the "www." I want to redirect any instance of the site with www to non-www. This includes internetbusinessdaily.net/index.php. No matter what, I want the final URL to look like: internetbusinessdaily.net/* *= anything after that doesnt matter. Here's what I have in my .htaccess so far: =================================== # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ========================================= How do i do this properly? Thanks!!!
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.*$ [NC] RewriteRule ^(.*)$ http://www.example.com/1$ [R=301,L] </IfModule> Try with above code.
Will this mess up the URL formatting that is already on the site? It already maps a database driven URL to a cleaner URL. The code you gave me doesnt seem to include some of the rules from the code i posted. can you confirm? thanks!
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.*$ [NC] RewriteRule ^(.*)$ http://example.com/1$ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> This is the final code.
This didnt work. I replaced example.com with my domain...and nothing changed from my old code. Did i do something wrong?
it should be: redirect 301 /oldsite/oldpage.htm http://www.newsite.com/newpage.htm Code (markup): never saw it being done that other way before.
it would forward just that folder. For instance, if you wanted to do one page to one page, it would be: redirect 301 http://www.newsite.com/oldpage.htm http://www.newsite.com/newpage.htm Code (markup):
definitely. Also, I'd recommend de-indexing links in your Google Webmaster account (Tools -> Remove URLS) if any of those URLs do not have backlinks.
but does that rule work in htaccess? does it account for every instance of the domain? i want any URL with WWW to redirect to nonWWW. thanks
i still dont have a working solution for this. can someone please help me. the code i currently have is at the top of this thread. i need to keep what is there but add the functionality to allow any page with www. to 301 redirect to non-www...regardless of what page it is. thanks
If you use wordpress, you should change WordPress address (URL) and Blog address (URL) in Options-> General
I also use wordpress and no problem with redirect. Watch the URL www.trip-tips.com or try this htaccess code RewriteEngine On RewriteBase / [B]RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC] RewriteRule ^(.*)$ http://yourdomain.com/1$ [R=301,L][/B] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Code (markup):