Locking the www in urls

Discussions about SEO Techniques implemented in your sites. Tests, Studies and results analysis.

Moderator: Moderators

Postby dcz » Sun Oct 26, 2008 9:56 am

So you are indeed using :
Code: Select all
RewriteCond %{HTTP_HOST} !^www\.dogs4sale\.net$ [NC]
RewriteRule ^(.*) http://www.dogs4sale.net/forum/$1 [QSA,L,R=301]


In the forum/ dir's .htaccess, correct ?

if so, try using :
Code: Select all
RewriteCond %{HTTP_HOST} !^www\.dogs4sale\.net [NC]
RewriteRule ^(.*)$ http://www.dogs4sale.net/forum/$1 [QSA,L,R=301]

I'm not 100% positive it will fix the issue, but it could.
Please note that you should still keep the original www prefix redirection in your domain's root .htaccess and implement this one in the forum/'s one.

If it does not make it, please post here you full phpBB3's .htaccess.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Advertisement

Re: Locking the www in urls

Postby IPB_Refugee » Sat Mar 14, 2009 6:16 pm

Hi,

just a small note: You can also do it without the domain name in .htaccess which is a bit more convenient when you have different sites because you can just copy & paste the code:

Code: Select all
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,L]


And when you have a subdomain called subdomain which should be available with

Code: Select all
http://subdomain.example.com


and not

Code: Select all
http://www.subdomain.example.com


just add this:

Code: Select all
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^subdomain
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,L]


Have a nice weekend!
Wolfgang
User avatar
IPB_Refugee
PR0
PR0
 
Posts: 82
Joined: Thu Jul 24, 2008 2:18 pm

Re: Locking the www in urls

Postby dcz » Mon Mar 16, 2009 11:25 am

Very true, but I kind of like to specify a bit more this kind of matter ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Re: Locking the www in urls

Postby jmueller0823 » Thu Oct 01, 2009 2:52 pm

DCZ

In your earlier post
Please note that you should still keep the original www prefix redirection in your domain's root .htaccess and implement this one in the forum/'s one.


What is best practice?
Should I have an htaccess in the site root AND an htaccess in my forums root?

Thanks.
Jim
jmueller0823
PR0
PR0
 
Posts: 54
Joined: Sat Dec 27, 2008 2:50 am

Re: Locking the www in urls

Postby dcz » Sat Oct 03, 2009 3:08 pm

There is not real best practice, you just need to implement this in the domain's root .htaccess as well as in any other directory using an .htaccess and starting mod_rewrite.

So, if your forum is installed in your domain's root, you don't have much choice, if it is installed in a sub directory, then you can either implement the forum .htaccess there or in the domain's root. In such case, if you do not implement the forum .htaccess in the domain's root (and this is only when you need and want to), then you'll need to place the www prefix redirection in both.

As well, note that our latest mod rewrite does generate the proper lines of code for this matter in the .htaccess, it is just left commented because it's the type of thing that need to be implemented once the .htaccess is fully functional, it looks like :
Code: Select all
# HERE IS A GOOD PLACE TO FORCE CANONICAL DOMAIN
# RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [QSA,L,R=301]


but with the proper domain name and path for your setup. So you can just remove the # before RewriteCond and RewriteRule to uncomment, should work ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Previous

Return to SEO Techniques

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 4 guests