SEO

Exclude directories from URL rewriting

Posted in SEO on December 3rd, 2009 by Ilir Fekaj – Be the first to comment

Rewriting your URLs as directories in .htaccess is a really cool feature which greatly improves usability and search engine visibility of your pages. However, this can make real directories inaccessible and you may wish to exclude these from being rewritten. For example, you might want to exclude your temp, stats or admin directory. The simplest way to do this would be to place the following code in your .htaccess file:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]

The first line of code checks if the directory requested by user exists on the server file system, and if it does exist, it doesn’t serve index.php. Second line does the same thing for files. In case request is not made for any files or directories that exist, it performs rewrite on index.php.
This works in many cases, but if you have more complex rewrites performed on several files, I found that this code does better job:

RewriteRule ^(temp|stats|admin)(/.*)?$ - [L]

Put all directories you want to exclude from rewrite in brackets and separate them with pipe symbol “|”.

Post to Twitter Tweet This Post

Prevent specific sites from hotlinking using .htaccess

Posted in SEO on October 10th, 2009 by Ilir Fekaj – Be the first to comment

When I first created AvatarsDB site, my idea was to allow people to simply link to individual avatar images without need to search for image hosts or download images to their computers. However, after some time there were people who started to abuse this service. I had cases when people built entire sites and blogs just by linking to thousands of images from my site. No need to mention that this wasted gigabytes of my bandwidth and sent hundreds of thousands of useless request to my server without providing even single link back. I wanted some solution which will allow legitimate users to use this service and block bandwidth leeching.

Solution is very simple and it involves editing your .htaccess file and creating replacement image which you will show to visitors of offending site. This can also bring some traffic to you if you put name or address of your site. Simply put this code in directory where you keep your images or in root if you wish to prevent hotlinking in all directories:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?evilhotlinker\.net/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?leecher\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?annoyance\.net/ [NC]
RewriteRule .*\.(jpg|gif|bmp|png)$ images/nohotlink.gif [L]

You can put as many sites in this list as you like, just make sure lines before last one on the list end with [NC,OR] which tells Apache to continue matching. If you want to save bandwidth, you can also send error 403 Forbidden by editing last line to this:

RewriteRule .*\.(jpg|gif|bmp|png)$ - [F]

You can also block all hotlinking and allow only your site:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com.*$ [NC]
RewriteRule .*\.(jpg|gif|bmp|png)$ images/nohotlink.gif [L]

You should put all these codes before you do any URL rewriting or they might not work. When you’re done editing, make sure you upload it in text mode or it also may not work.

Post to Twitter Tweet This Post

Things to avoid when optimizing sites for Google search

Posted in SEO on March 20th, 2006 by Ilir Fekaj – 7 Comments


I spent last five years researching how to improve my site’s search engine positions without interfering with experience of my visitors. Perhaps I haven’t figured out what should I do, but now I definitely know what techniques to avoid ;)

The first and most important thing to keep in mind when you start thinking about ways to optimize your pages is that you’re building pages for your visitors, not search engines. Techniques described bellow will interfere with your users experience and (in most cases) will result in disappearance of you sites from SERP’s.

Bad navigation

Your website must have clean and simple navigation. This way you ensure that Googlebot is able to crawl your entire site. Navigation links should be located near the top of the pages since this makes it easy for your visitors and Googlebot to navigate through your site. Best bet for navigation is use of text links, as this increases word count and keyword density, as well as giving description of destination page to Googlebot. Googlebot is also able to follow image links and from recently Flash navigation links. If you use image links make sure you add some description in ALT attribute of image tag to describe your link.

Keyword stuffing in image ALT text

Some webmaster and optimizers still believe that inserting dozens of keywords or keyphrases in image ALT text will improve their search engine rankings. Well, this is wrong since search engines are able to detect this technique and they now almost completely ignore ALT text.

This is definitely one of the ugliest SEO techniques. You may ask, “Why is this so bad when only search engines are able to see this text?”. Just imagine how people with disabilities feel when their screen readers stumble reading dozens or even hundreds of keywords describing your image. In addition, your site will look very ugly in text-only browser like Lynx.

On the other hand, few very well chosen words to describe your images will improve your user’s experience and may even slightly improve your search engine rankings.

JavaScript links

Googlebot is not able (currently) to follow JavaScript links. People often use these type of links for fancy navigation. If you use them just make sure you have alternative navigation using HTML links.

Hidden text

Googlebot and other robots learned to recognize this method several years ago. So if you don’t want to be identified as spammer and banned from SERP’s, don’t use this method. Like with keyword stuffing in image ALT tags, this technique will create nightmare for users with disabilities who use screen readers.

Hidden links

Number of incoming links to certain page has direct effect to Google PageRank (PR). However, if those are hidden that may produce similar results as with hidden text.

Cloaking

Cloaking is a search engine optimization method where you serve highly optimized page version to robots and a regular page to your visitors. Official Google policy is that cloaked pages are not allowed in their index. However, there are many websites that use cloaking with great success. So if you like to risk getting banned from SERP’s you may use this method, just make sure you do it properly.

Guest book spamming and FFA pages

Adding your link to hundreds of guest books will not help you with your PR, since it appears that Google is able to detect them and ignores outgoing links completely. This way you’ll save yourself many hours of useless work. When PR was initially introduced, many SEO companies were offering to “submit your site to zillion FFA pages for free” and hopefully increase your PR. I don’t remember that this used to work at time and it certainly doesn’t work now. If you find any of these, avoid them.

Sessions

Google is not able to accept session cookies and will try avoiding URL based sessions. Also, you should use fewer parameters in you dynamic URLs and avoid use “id” parameter as Googlebot may think that is session ID.

General rule for all serch engines

When you’re planning to use some technique and you believe that it looks spammy, then it probably is spammy ;)

Post to Twitter Tweet This Post