Directory Redirect on Apache Server

I downloaded a simple PHP blogging template called sphpblog and put it on my server. The blog is accessed through classlibrary.org. This domain redirects to the folder /other/william/classlibrary on the server. I can visit the homepage of the blog, and it displays just fine. However, when I try to click links, the links go to classlibrary.org/other/william/classlibrary/linkname.extension, which results in a 404 error. I checked the preferences for the blog and there is no option to have it direct to the root directory of the website. So, I would like to have any link going to classlibrary.org/other/william/classlibrary/filename.extension redirect to classlibrary.extension.

Rather then creating seperate html files for each file on the server, which would take a while, can I somehow do this through a .htaccess file? My server is running PHP version 5.2, and the full path classlibrary.org redirects to is /home/content/r/t/e/rteder10/other/william/classlibrary. I don't have access to the administrator control panel or access or the server itself. It is Godaddy Linux Hosting. Any help will be greatly appreciated.

-

Assuming that the server is configured to allow overrides, you can use mod_rewrite to create all kinds of mappings. I'm afraid the specifics of your situation are somewhat convoluted. I'm not clear where you are keeping these lists and if there is any coherent rule to how they are built. If there is a system, you could use mod_rewrite like this:

RewriteEngine on
RewriteRule ^/other/william/classlibrary/([a-z]*).ext  /other/william/classlibrary/\$1library.ext


However that only works if the linkname matches the classname somehow. You can find out more about mod_rewrite at http://httpd.apache.org/docs/current/mod/mod_rewrite.html

If the relationship is too complicated or arbitrary for a regular expression and backreference to be useful, you can use a rewritemap which will allow you to create a table of arbitrary rewrites. http://httpd.apache.org/docs/2.3/rewrite/rewritemap.html

If all this seems too complicated and you don't have too many redirects, you could just use the simpler redirect command to do them one by one in the .htaccess file:

Redirect  /other/william/classlibrary/filename.extension http://classlibrary.org/other/william/classlibrary/classlibrary.extension

-

You can as well create simple 404-error handler, which will analyze request URL and, if URL is the one you need, create a copy of the page with needed name. So, site will auto-update itself on first request, and then no redirection will be needed as new (right-named) file will be in place.

In 404 error handler script as you create a new file you'll then reply (to the user) http code 200 and page content so even on first visit visitors won't see error.

-