![]() |
|
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Servers Servers and operating sytems talk. |
![]() |
|
|
LinkBack (5) | Thread Tools | Display Modes |
|
|||
|
Sometimes you may find that you have both www and non-www versions of your site e.g http://www.mysite.com & http://mysite.com indexed in the SERPs which not only looks messy but could possibly lead to your site being penalised for duplicate content. One method to prevent this is to use Apache's mod_rewrite to change the URLs.
This is how you would use it to change non-www to www Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^MySite.com [NC]
RewriteRule ^(.*)$ http://www.MySite.com/$1 [L,R=301]
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.MySite.com [NC]
RewriteRule ^(.*)$ http://MySite.com/$1 [L,R=301]
__________________
Lawrence |
![]() |
LinkBacks (?)
LinkBack to this Thread: http://www.eshopforums.com/f30/how-301-redirect-non-www-urls-www-ones-vice-versa-using-htaccess-632/
|
|||
| Posted By | For | Type | Date |
| 301 re-direct - Page 2 - UK Business Forums - business help and advice for owners, managers and entrepreneurs of small businesses and startups | This thread | Refback | 20-02-2008 07:30 PM |
| Digg / Linux/Unix / Upcoming | This thread | Refback | 27-10-2007 12:27 AM |
| Digg / Linux/Unix / Upcoming | This thread | Refback | 26-10-2007 07:47 PM |
| Digg / Linux/Unix / Upcoming | This thread | Refback | 26-10-2007 02:45 PM |
| Digg - How to 301 redirect non-www URLs to www ones and vice-a-versa. | This thread | Refback | 26-10-2007 02:43 PM |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use .htaccess to block IPs and domains from your website. | Lawrence | Servers | 1 | 04-07-2008 10:40 PM |
| How to use mod_rewrite to block bad bots with .htaccess | Lawrence | Servers | 0 | 30-10-2007 03:25 AM |
| How to perform a HTTP 301 redirect in PHP (Search engine friendly) | Lawrence | PHP/MySQL ASP.net and other server side technologies | 0 | 29-09-2007 12:37 AM |
| How to do a page redirect using HTML meta tags. | Lawrence | HTML/XHTML CSS & JavaScript | 2 | 26-08-2007 11:20 AM |