Archive for the ‘Apache’ Category

Once a URL goes live plan to maintain it forever

Tuesday, June 5th, 2007

Yes it may sound crazy but once a URL goes live you must maintain it… forever! (if SEO is your thing that is). Now that isn’t to say that you shouldn’t change or remove some URL’s, just make sure you create an Apache rewrite rule utilizing a 301 redirect. I deal with this on a monthly basis at work and its not so bad as long as you track your URL movements. Rewrites are an SEO’s best friend. Here is a good way to check to see if a Google has any records of a given string in your URLs:


http://www.google.com/search?q=site:designmills.com+inurl:seo
http://www.google.com/search?q=site:designmills.com+inurl:2002

Redirecting all subdomains to www

Thursday, April 12th, 2007

In order to get the cleanest and best ranking possible, always redirect your subdomains (the ones not in use) to www! I cant stress this enough. When Google comes by and sees that http://site.com and http://www.site.com are the same it thinks that this is duplicate content, which it is! I just implemented this today for my friends site A1 Imports Autoworks. Go ahead, try it. Here is the rewrite for Apache:

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

Use Apache Rewrites much like an ‘if’ block

Friday, February 23rd, 2007

Recently I had to fabricate some nasty rewrite rules involving some unruly query parameters where if one was present do this, whereas if two were present do that, or if none were present redirect somewhere else. I had to step back after a few hours of work to try and look at this problem differently. All of sudden it became clear. Some code is omitted but here are two examples that I am using in production:


RewriteCond %{QUERY_STRING} ^pid=([0-9]+)&pid=([0-9]+)
RewriteRule ^/oldurl.html
   http://%{HTTP_HOST}$1/newurl.html?%{QUERY_STRING} [R=301,L]

RewriteCond %{QUERY_STRING} ^pid=([0-9]+)
RewriteRule ^/oldurl2.html
   http://%{HTTP_HOST}$1/newurl2.html? [R=301,L]


As you can see I am setting up gates or switches. The list went on and on and the order is highly important as you may notice, just as some ‘if’ blocks are (consider refactoring). In the case of a top-down script like mod_rewrite I feel this is not only acceptable but necessary to accomplish this task.