| 
 
 
 | 
| Keep Server Online 
 If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
 
 or
 
 
   
 A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
 
 Thank You! Steffen
 
 Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |  | 
 | 
| | 
| | 
|  Topic: Solve canonical domain issue and Protect your Page Ranking |  |  
| Author |  |  
| SMc 
 
 
 Joined: 12 Feb 2006
 Posts: 17
 Location: Chelmsford, UK
 
 | 
|  Posted: Thu 06 Jul '06 15:33    Post subject: Solve canonical domain issue and Protect your Page Ranking |   |  
| 
 |  
| Hi, 
 The canonical domain issue can damage your search engine rankings because you appear to have two identical web pages with the same content. e.g.
 
 http://www.giftofsound.co.uk/
 http://giftofsound.co.uk/
 
 ...in other words, if you allow both of the options above to resolve, then your search engine page rank will be affected because search engines will see that as duplicate page content and demote accordingly.
 
 To avoid this it is necessary to set up so that when someone types in http://giftofsound.co.uk the server makes a 301 re-direct to http://www.giftofsound.co.uk and your page rank is fine (a real example showing the re-direct in action).
 
 It can happen by accident or if anyone (perhaps a competitor for your ranking) displays a link to the non-www version of your site somewhere on the internet.
 
 This can be solved by using a 301 re-direct from the server from one to the other (doesnt matter which one you choose as long as there is only 1)
 
 This example assumes you want to re-direct all non-www to your www.
 
 First of all make sure you have uncommented the following line in the httpd.conf...
 
 LoadModule rewrite_module modules/mod_rewrite.so
 
 Now insert the following code into the virtual host container of your httpd.conf, or in the \extra\httpd-vhosts.conf depending on your setup.
 
 <IfModule rewrite_module>
 Options +FollowSymLinks
 RewriteEngine on
 RewriteLog logs/rewrite.log
 RewriteLogLevel 9
 #
 RewriteCond %{HTTP_HOST} !^www\.yourDomain\.co\.uk
 RewriteCond %{HTTP_HOST} !^$
 RewriteRule ^/(.*) http://www.yourDomain.co.uk/$1 [R=301,L]
 </IfModule>
 
 NOTE: The RewriteLogLevel is set to 9 for development, but can be set to 0 for production to reduce log size
 
 Now your server returns a search engine friendly 301 redirect and you have some protection.
 
 
 Regards,
 
 SMc
 |  |  
| Back to top |  |  
| DeliriumServers 
 
 
 Joined: 17 Jun 2006
 Posts: 54
 Location: H Town
 
 | 
|  Posted: Wed 12 Jul '06 3:55    Post subject: a way |   |  
| 
 |  
| is there a way that you can have this automatically done for any domain name, like wildcard? so that I could use mod_vd and this together? |  |  
| Back to top |  |  
| SMc 
 
 
 Joined: 12 Feb 2006
 Posts: 17
 Location: Chelmsford, UK
 
 | 
|  Posted: Wed 12 Jul '06 14:24    Post subject: |   |  
| 
 |  
| Hi Delirium, 
 ...well the documentation link posted by Steffen suggests it can be used with mod_rewrite depending on the module execution order in the conf file.
 
 So I would give that a test making sure the rewite example I posted earlier is first and then your mod_vd after that. Then I would expect the following:-
 
 1 - Request to your server
 http://domain.com/images/fred.jpg
 
 2- Permanent Re-Direct
 http://www.domain.com/images/fred.jpg
 
 3- Appliy your mod_vd config (example from your other post)
 F:/www/com/domain/images/fred.jpg
 
 I believe a generic way to apply the mod_rewrite is to place it earlier in the httpd.conf and then put the following in your virtual host configs
 
 RewriteEngine on
 RewriteOptions inherit
 
 
 Let us know if that works
 
 Regards,
 
 SMc
 |  |  
| Back to top |  |  
| DeliriumServers 
 
 
 Joined: 17 Jun 2006
 Posts: 54
 Location: H Town
 
 | 
|  Posted: Thu 20 Jul '06 23:23    Post subject: |   |  
| 
 |  
| SMc, 
 Is it possible to create a rewrite rule that would redirect or remove the www before it was passed to mod_vd?
 
 so if someone entered http://deliriumservers.com mod vd would send it straight to the correct folder
 
 if someone entered http://www.deliriumservers.com mod_rewrite would remove the www before the request was passed to mod_vd
 
 or if someone entered http://www.subdomains.deliriumservers.com mod_rewrite would remove the ww and allow mod_vd to function
 
 basically mod_rewrite would just have to identify if www was at the beginning and remove it.
 
 Thanks for the help, I really appreciate it
 Delirium
 |  |  
| Back to top |  |  
| DeliriumServers 
 
 
 Joined: 17 Jun 2006
 Posts: 54
 Location: H Town
 
 | 
|  Posted: Mon 31 Jul '06 22:42    Post subject: |   |  
| 
 |  
| here's what works for me!! 
 you can put this inside your httpd.conf plain or in a virtual host, whatever, but get the rewrite rule ahead of mod_vd
 
 RewriteEngine on
 RewriteCond %{HTTP_HOST} .
 RewriteCond %{HTTP_HOST} !^www. [NC]
 RewriteRule (.*) http://www.%{HTTP_HOST}$1 [R=301,L]
 
 <IfModule vd_module>
 VdEnable on
 VdChopPrefix 1
 VdChopSuffix 0
 VdPathPrefix F:/www/webroot
 </IfModule>
 
 
 And it works!!!!! If there is no www, then it adds it, if there is it leaves it alone.  With mod_vd set to just eat the www, everything works great!!
 |  |  
| Back to top |  |  
 
 | 
 |  | 
 |  |