![]() |
|
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| PHP/HTML/CSS/JavaScript and Servers Pick up tips and exchange info on the technical side of having a web presence. |
![]() |
|
|
LinkBack (6) | 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 |
![]() |
| Tags |
| .htaccess, 301 redirect, url rewrite |
LinkBacks (?)
LinkBack to this Thread: http://www.eshopforums.com/f31/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 - the UK's most active help and advice forum for owners, managers and entrepreneurs of small businesses and startups. | This thread | Refback | 10-05-2008 12:51 PM |
| 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 08: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 | PHP/HTML/CSS/JavaScript and Servers | 1 | 04-07-2008 10:40 PM |
| How to use mod_rewrite to block bad bots with .htaccess | Lawrence | PHP/HTML/CSS/JavaScript and Servers | 0 | 30-10-2007 04:25 AM |
| How to perform a HTTP 301 redirect in PHP (Search engine friendly) | Lawrence | PHP/HTML/CSS/JavaScript and Servers | 0 | 29-09-2007 12:37 AM |
| How to do a page redirect using HTML meta tags. | Lawrence | PHP/HTML/CSS/JavaScript and Servers | 2 | 26-08-2007 11:20 AM |