Php on UO Shell the bare minimum

I wanted to redirect a shell site to a new WPMU site on the UO’s Web Site Lite setup. http://sites.uoregon.edu/. Web Site Lite is great, but it has limitations. Since I wanted to redirect all the old links to the new site I set up a .htaccess file that bounces all requests from the old site to the new site.
To do just that I could use:

Redirect 301 /~oa/ http://oa.uoregon.edu/ #works but I'd like to remove .php and .html

But I wanted to remove the file extensions before redirecting.
For that I needed to use Mod Rewrite. Which means I needed to enable php on shell.
There used to be a post: Easy PHP on shell by Tristan but that page is down so I looked at my other domain on shell and it turns out, all I needed to do is put a php.cgi file in the public_html folder and add some lines to the top of my .htaccess file. Now the mod_rewrite script can run!

# Redirect 301 /~oa/ http://oa.uoregon.edu/ #works but I'd like to remove .php and .html

RemoveHandler .php
AddType application/my-httpd-php .php
Action application/my-httpd-php /~oa/php.cgi
RewriteEngine on
RewriteBase /
RewriteRule (.*).html$ /$1
RewriteRule (.*).htm$ /$1
RewriteRule (.*).php$ /$1
RewriteRule ^(.*)$ http://oa.uoregon.edu/$1 [R=301,L]

So that code removes any of those three file extensions and redirects to the new domain.
I suspect I could combine all three extensions into one regex but it works and I’m moving on to the next item on my list.

Leave a Comment