Skip to content Skip to navigation

Removing cgi-bin from your URL

Posted by: 

Updated and Reviewed on 2012-05-03

Web applications like Drupal only run within the cgi-bin directory of your AFS space, but URLs such as are ugly, hard to read and take longer to type.

The recommended solution is to use a vanity URL or virtual host such as which can be requested from and will effectively hide the full URL.

If for some reason you don't want to do that and would prefer to have your URL start with (as in, read on.

.htaccess tweaks

When people request, the web server reads the content as found in /afs/ir/dept/foo/WWW. The instructions below tell the web server to send all those requests, transparently, to the cgi-bin directory, in /afs/ir/dept/foo/cgi-bin/drupal instead.

Create an .htaccess file in /afs/ir/group-or-dept/your-group-dept-name/WWW, and enter the following lines:

RewriteEngine On
RewriteBase /group-or-dept/your-group-dept-name/
RewriteRule ^/?(.*)$ cgi-bin/your-drupal-directory/$1

In the example above, using /dept/foo and /dept/foo/cgi-bin/drupal the .htaccess in WWW would read:

RewriteEngine On
RewriteBase /dept/foo/
RewriteRule ^/?(.*)$ cgi-bin/drupal/$1


Edit the sites/default/settings.php file and set the $base_url to the URL without the /cgi-bin/ portion. In the example above, the line would read:

$base_url = ''; // NO trailing slash!