On the server with the html files, you need to add a Redirect command
to the .htaccess file (and possibly enable overrides in the httpd.conf
The redirect format is the same in Apache version 1.3 and 2.0, see
respectively. In brief, adding a line like
Redirect 301 /html_dir http://your.web.site.here/php_dir
to the .htaccess file would do the job.
There are a number of references found when searching with a phrase like
http 301 redirect apache htaccess
has a couple good examples and includes the reference to allowing
overrides (if you don't do so previously).
which describes more than one method - the Redirect command described
above is the "preferred method" but the other methods will work as
well (with perhaps side effects - the text has details).
which describes the method with some cautions for FrontPage extension use.
similar content, but adds an example of redirect using PHP.
If you need further explanation or if some part of the answer is
unclear, please request a clarification.
Request for Answer Clarification by
11 Oct 2005 16:41 PDT
Ok, first of all, I am using Macromedia dreamweaver to work on my
sites. When i access my files for the site, there is neither a
.htaccess file nor a httpd.conf file that i can see--that's because i
never created one, and only what i created is up there (for example,
my main /index.html file, some pictures, etc.)
So i created a .htaccess file, which is a regular notepad (.txt) file
with simply nothing except the code you gave me, "Redirect 301
/html_dir http://my.web.site.here/php_dir"---with the site url i want
to redirect to, of course.
I load it up, and now it's up there when I look at Remote Acces view
on Dreamweaver. However, i type in my url and its not working. What's
Clarification of Answer by
11 Oct 2005 18:25 PDT
From what you described, I assume the .htaccess file was added to the
same directory as your web pages. Please confirm this and that the
file has that name (w/o any file types like .txt or .html). If you
used Notepad to create the file, it may have .txt added - rename the
file if needed and upload again.
Note also that the apache configuration file must allow for overrides
(this is described as the default, but it may be disabled on your web
server). The location of the httpd.conf file varies by version and
Linux distribution. It should be somewhere under /etc, usually
something like /etc/httpd/conf/httpd.conf (e.g., Red Hat 8.0). If you
don't have direct access to that file, ask your system administrator
if overrides are allowed (and if not, how to get them enabled).
If you need to modify httpd.conf yourself, there is a nice commented example at
which disables all overrides as the default and enables overrides only
for specific directories. I could certainly suggest the needed changes
if you make a copy of the configuration file available to view or if
you indicate the key commands (e.g., AccessFileName, AllowOverride).