Blog

.htaccess PREVENTING DIRECTORY LISTING

17.07.2009 0

Do you have a directory full of images or zips that you do not want people to be able to browse through? Typically a server is setup to prevent directory listing, but sometimes they are not. If not, become self-sufficient and fix it yourself:

IndexIgnore *

The * is a wildcard that matches all files, so if you stick that line into an htaccess file in your images directory, nothing in that directory will be allowed to be listed.

On the other hand, what if you did want the directory contents to be listed, but only if they were HTML pages and not images? Simple.

IndexIgnore *.gif *.jpg

This would return a list of all files not ending in .jpg or .gif, but would still list .txt, .html, etc.

And conversely, if your server is setup to prevent directory listing, but you want to list the directories by default, you could simply throw this into an htaccess file the directory you want displayed:

Options +Indexes

If you do use this option, be very careful that you do not put any unintentional or compromising files in this directory. And you can throw in a minus sign

Options -Indexes

to prevent directory listing entirely–this is typical of most server setups and is usually configured elsewhere in the apache server, but can be overridden through htaccess.

If you really want to be tricky, using the +Indexes option, you can include a default description for the directory listing that is displayed when you use it by placing a file called HEADER in the same directory. The contents of this file will be printed out before the list of directory contents is listed. You can also specify a footer, though it is called README, by placing it in the same directory as the HEADER. The README file is printed out after the directory listing is printed.

Migrate email from Thunderbird to Entourage OS X

14.07.2009 3

I recently had a friend that got a new Mac and was trying out different email clients. They ended up using Entourage (I never said they were perfect..) and had allot of emails on Thunderbird that they wanted to have migrated over to Entourage.

They contacted me and I thought it would be a snap to do. While it was not very hard. I did think it was excessively difficult for anyone that’s not immersed in the tech world. Even more so to someone new to Mac & OS X.

So the following is a detailed step by step guide on how to migrate email from Thunderbird to Entourage OS X.

In this guide you will:

  • Prepare Thunderbird email files to be converted to Entourage ready files
  • Import the newly created files into Entourage

Entourage will not accept any files unless they have an extension of “.mbx”. Of course, Thunderbird doesn’t create these file types. So you need to make copies of the Thunderbird files, make copies of them and run a simple AppleScript to convert to data in the files to something Entourage understands. If this sounds intimidating, don’t worry. We’ll do this together nice and slow. I promise nobody will get hurt =]

Locate the Thunderbird folders you want to import. They live in

~/Library/Thunderbird/Profiles/you_profile_name_here/Mail/Local Folders/

NOTE:
The tilde key “~” denotes your user profile. In my case the file path to my local folders directory is:

jonbritt/Library/Thunderbird/Profiles/my_profile_name_here/Mail/Local Folders/

In the following example, I’m going to use the file, “Unsent messages” You will need to repeat this process for every folder you’d like to migrate from Thunderbird to Entourage

Make a copy of the file by selecting, “Unsent Messages.msf”. Then select CMD + “C” to copy the file then press CMD + “V” to paste the file, thus making a copy of the file.

After you made a copy of “Unsent Messages.msf” you will have two files. The original file named, “Unsent Messages.msf” and one named “Unsent Messages.msf copy”

  1. Select the file “Unsent Messages.msf copy” by clicking on it once
  2. Wait a short moment and click on the same file. This will bring up the ability to rename the file w/ no CTRL or Right click
  3. Rename the file from “Unsent Messages.msf copy” to “Unsent Messages.mbx” *YOU may be asked to validate you want to change file extension. If so, say OK

You will then have two separate files that share the same name, but have different extensions.
“Unsent Messages.msf”
“Unsent Messages.mbx”

Repeat this process with all folders you want to migrate from Thunderbird to Entourage before proceeding with the next step.

Click on this link and save it to your desktop. *This file is a script that is going to convert your files for you.

Expand the .zip file by double clicking on it. This will place a file on your desktop named, “Thunderbird” *Image below.

Double click on the extracted file. Image below
thunderbird1

This action will launch the Script Editor with a bunch of multi-colored text.
script_screen

Click “Run”.

YOU’VE DONE IT! Your done with the hard part, now it’s time to import the messages into Entourage.

Launch Entourage.

Select File>Import

Then select the following options:

  1. Contacts or messages from a text file
  2. Import messages from an MBOX-format text file
  3. Navigate to the same location of the folders you just created
  4. Select all the files that have the “.mbx” extension that you created earlier

Select, “Import”

After that tedious ordeal. You should be able to see all your messages in Entourage.

Hope this proves helpful for someone out there =]

.htaccess REDIRECTS

11.07.2009 0

Ever go through the nightmare of significantly changing portions of your site, then having to deal with the problem of people finding their way from the old pages to the new? It can be nasty. There are different ways of redirecting pages, through http-equiv, javascript or any of the server-side languages. And then you can do it through htaccess, which is probably the most effective, considering the minimal amount of work required to do it.

htaccess uses redirect to look for any request for a specific page (or a non-specific location, though this can cause infinite loops) and if it finds that request, it forwards it to a new page you have specified:

Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html

Note that there are 3 parts to that, which should all be on one line :

  1. the Redirect command
  2. the location of the file/directory you want redirected relative to the root of your site (/olddirectory/oldfile.html = yoursite.com/olddirectory/oldfile.html)
  3. the full URL of the location you want that request sent to.

Each of the 3 is separated by a single space, but all on one line. You can also redirect an entire directory by using

Redirect /olddirectory http://yoursite.com/newdirectory/

Using this method, you can redirect any number of pages no matter what you do to your directory structure. It is the fastest method that is a global affect.

Speed Up Slow Firefox 3.5 Windows Start-Ups

10.07.2009 0

Firefox 3.5 pulls data from certain file locations for randomized security purposes. Sometimes, though, that can lead to annoying slow start-ups in Windows. You can speed things up by cleaning out certain folder locations.

Having too many temporary, history, or recent document files sitting in your Windows locations slows down Firefox 3.5’s performance, as has been reported as a bug. The Mozilla Links blog recommends cleaning out these folders to move the browser’s work along.
To run the following lines of code:
1. Click Start

2. Right Click “Run” and select “Run as administrator”

1
2
3
4
C:\Documents and Settings\*user*\Local Settings\History
C:\Documents and Settings\*user*\Local Settings\Temporary Internet Files
C:\Documents and Settings\*user*\My Recent Documents
C:\Documents and Settings\*user*\Temp\

On Vista or Windows 7 systems, simply replace “Documents and Settings” with “Users.” Setting up Firefox to automatically clean out your temporary files after browsing, as explained below, helps prevent the accumulation from building again.

Want to do it even quicker than entering those lines of code? Try this if your a little courageous:

1. Click Start

2. Right Click “Run” and select “Run as administrator”

3. Type: notepad and press enter.

4. Once notepad is open, type the below lines in the file or copy and paste the below lines into notepad.

1
2
3
4
5
6
del  /s  /q    %TEMP%\*.*
del  /s  /q     %TMP%\*.*
del  /s     /q  %SystemDrive%\temp\*.*
REM del  /s    /q   %SystemDrive%\tmp\*.*
del  /s      /q  %windir%\prefetch\*.*
del  /s    /q   %windir%\Temp\*.*

5. Click File and click Save; browse to where you want to save the file. For the file name, type “firefoxclear.bat” (or whatever, just make sure the file extension is “.bat”).
NOTES:
If your version of Windows has a “Save as type” option, choose “All files”, otherwise it will save as a text file.
Also ensure the Encoding uses ANSI.
Once all of this has been done click the Save button and exit notepad.

6. Now, execute the batch file, simply double-click or run the file like any other program. Once the batch file has completed running it will close the window automatically.

.htaccess PREVENTING HOTLINKS

09.07.2009 0

In the webmaster community, “hot linking” is a curse phrase. Also known as “bandwidth stealing” by the angry site owner, it refers to linking directly to non-html objects not on one own’s server, such as images, .js files etc. The victim’s server in this case is robbed of bandwidth (and in turn money) as the violator enjoys showing content without having to pay for its deliverance. The most common practice of hot linking pertains to another site’s images.

Using .htaccess, you can disallow hot linking on your server, so those attempting to link to an image or CSS file on your site, for example, is either blocked (failed request, such as a broken image) or served a different content (ie: an image of “the bird”) . Note that mod_rewrite needs to be enabled on your server in order for this aspect of .htaccess to work. Inquire your web host regarding this.

With all the pieces in place, here’s how to disable hot linking of certain file types on your site, in the case below, images, JavaScript (js) and CSS (css) files on your site. Add the below code to your .htaccess file, and upload the file either to your root directory, or a particular subdirectory to localize the effect to just one section of your site:

1
2
3
4
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|js|css)$ - [F]

Be sure to replace “mydomain.com” with your own. The above code creates a failed request when hot linking of the specified file types occurs. In the case of images, a broken image is shown instead.

Serving alternate content when hot linking is detected

You can set up your .htaccess file to actually serve up different content when hot linking occurs. This is more commonly done with images, such as serving up an Angry Man image in place of the hot linked one. The code for this is:

1
2
3
4
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/thebird.gif [R,L]

Same deal- replace mydomain.com with your own, plus thebird.gif.