23

Jul

Filed in Code, JavaScript |

Since everything on page one of google isn’t, well, perfect, here’s a fully working example where you don’t need to type in your silly domain name.

# redirect all non-www traffic
RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9\-]*)\.com$
RewriteRule ^.*$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

For the unknowing, this code uses mod_rewrite.

No Responses to "Redirect Non-WWW Requests to WWW"

Subscribe to this topic with RSS or get the Trackback URL

Leave A Reply

 Username (*required)

 Email Address (*private)

 Website (*optional)

Note: Comments moderation may be active so there is no need to resubmit your comment.