Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I downloaded a simple PHP blogging template called sphpblog and put it on my server. The blog is accessed through 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, 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 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 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.

share|improve this question
up vote 3 down vote accepted

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

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.

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
share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.