|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Htaccess www to non www
I hear its a good idea to pick your preferred domain in google webmaster tools and also to redirect one to the other via htaccess such as the example below
Here is the code you should use if you want people to redirect from WWW to non-WWW: (for example, if someone types in http://www.domain.com, it will forward to http://domain.com) RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC] RewriteRule ^.*$ http://domain.com%{REQUEST_URI} [R=301,L] In both cases, make sure to replace “domain” with the URL of your domain. My question is this, I have a wordpress blog inside a subdirectory. Do I have to do anything different with the root htaccess file or will it just flow through my site. Second when it comes to wordpress I have a htaccess file in the and in the blog directory, do i have to enter it in both? Thanks |
|
#2
|
||||
|
||||
|
Hi Zoddy,
First of all, the "normal method" would be to redirect from "non-www" to "www" ('though it's not really important because what you're doing here will create your "standard"). The following code is much more straightforward: RewriteEngine On Just select the relevant one and put it in the .htaccess file at your domain root and it will work for the entire domain (including subfolders).
__________________
ClickyB "The quality of the visitor is more important than the volume".. Egol 22nd Feb 2008
New to SEO? Start Here: SEO FAQForum Rules & Posting Guidelines Last edited by ClickyB : June 29th, 2007 at 06:09 AM. |
|
#3
|
|||
|
|||
|
|
|
#4
|
||||
|
||||
|
Quote:
![]() 1. Back up your .htaccess file. 2. Add the code. 3. Upload the .htaccess file. 4. Try to access your domain index with "www". 5. Try to access your domain index without "www" (you should automatically be forwarded to the same url "with www"). 6. Try to access a url deep inside your domain without "www" (you should automatically be forwarded to the same url - "with www"). 7. If it doesn't work correctly, re-upload the original .htaccess |
|
#5
|
|||
|
|||
|
well i tried both versions up top and it kind of works.
The main page that doesnt have the blog at the root works great. You can type in domain.com and you are redirected to www.domain.com However the blog doesnt redirect it either does one of two things depending on which code I use above 1. I tried it with a deep embedded post and all it does is redirect me to the index page 2. Or it does nothing at all |
![]() |
| Viewing: SEO Chat Forums > Google > Google Optimization > Htaccess www to non www |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|