Apache RedirectMatch wildcard examples

Apache Redirect 301 FAQ: How can I redirect many old web pages using the Apache Redirect or RedirectMatch syntax and wildcard patterns (regex patterns)?

I'm currently trying to fix a lot of URLs that I more or less intentionally broke when I deleted the old "directory" portion of this website. In short, after removing the directory, no URL at "/Dir" work any more, so I have thousands of broken URLs (technically "URIs") that look like this:

Letting Google know about broken links I've fixed

Last night I spent some time going through my Google Webmaster's account, and found a listing of a large number of links I had broken on this website, largely because I removed the old, stale "directory" I had on this site. That was a Yahoo-style phonebook directory that made sense in 1999, but doesn't make much sense in 2011.

An Apache 301 redirect for a deleted directory

I recently reorganized the website, and as part of that, I deleted an entire directory at the root level that was named "/Dir". This was the "directory", where I had a Yahoo-like directory of links to applets, tutorials, CGI scripts, and so on, so I had thousands of web pages with URLs like these:

How to redirect Unix/Linux STDOUT and STDERR to the same file/location

Unix/Linux redirection FAQ: How do I redirect Unix STDOUT and STDERR to the same file with one command?

To redirect both STDOUT and STDERR to the same file with one Unix/Linux command, use this syntax: > /dev/null 2>&1

As you can see in this command, I'm redirecting STDOUT to /dev/null as normal, and then the special 2>&1 syntax tells your Bash shell to redirect STDERR to STDOUT (which is already pointing to /dev/null).

Perl redirect - a Perl CGI redirect example

Perl CGI redirect FAQ: Can you share some Perl CGI redirect example code?

Here's the source code for a simple Perl CGI redirect example. An HTML redirect is pretty easy to program manually, but the Perl module makes it even easier to redirect a user from one page to another.

Perl redirect CGI script example

Here's the source code for this Perl CGI redirect example script:

Linux `sort` command examples

Linux sort command FAQ: Can you share some examples of the Unix/Linux sort command?

As its name implies, the Unix/Linux sort command lets you sort text information. This article shares several examples of the Linux sort command.

Sorting ls command output

You can use the Linux sort command to sort all kinds of output from other commands. For instance, here's an example where I sort the output of the ls -al command:

How to test for a valid user session in a JSP

Note: This approach is very old; Java/JSP scriptlets were deprecated a long time ago. I don't have time to update this article to the correct, modern approach, but I hope this JSP session example will point you in the right direction.

Every once in a while I'm asked something like, "How can I tell if I have a valid user session in my JSP code?"

PHP redirect - How to send a redirect with PHP

PHP redirection FAQ: How can I redirect a user in a PHP script?

I've been working with OpenSSO a lot lately (Sun's open source identity management product), and one thing you see right away is that they redirect the user's browser a lot during the login process. During a typical login process a user will attempt to access a protected page; an OpenSSO agent will redirect the user's browser to the OpenSSO login page; and after a successful login they redirect you back to the protected resource.

Ruby system example - how to make system calls and redirect output to a file

I still have a lot to learn about Ruby, but here's a Ruby script that runs a series of system commands (Kernel.system()), which in my case means calling a series of JRuby scripts. I send all of the output from this script and from the system calls to a file by (a) writing directly to the file using Ruby and (b) redirecting STDOUT when making each system() call. I think this is a hack, but I can't find a better way to redirect STDOUT.