Google Answers Logo
View Question
Q: 301 redirects ( Answered 5 out of 5 stars,   0 Comments )
Subject: 301 redirects
Category: Computers > Internet
Asked by: johnazrael-ga
List Price: $5.00
Posted: 05 Oct 2005 17:22 PDT
Expires: 04 Nov 2005 16:22 PST
Question ID: 576900
How do i do a 301 redirect from an html-based site to a php site?

Request for Question Clarification by maniac-ga on 05 Oct 2005 17:32 PDT
Hello Johnazrael,

The redirect should be straight forward but the instructions for doing
so are different for the different web servers. Which one are you
using (e.g., Apache) and do you have the ability to change the
configuration files (e.g., .htaccess)?


Clarification of Question by johnazrael-ga on 06 Oct 2005 10:42 PDT
the servers are Linux with Apache, and yes, I have the ability to
chnage the config files such as .htaccess.
Subject: Re: 301 redirects
Answered By: maniac-ga on 06 Oct 2005 16:56 PDT
Rated:5 out of 5 stars
Hello Johnazrael,

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
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
For example,
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 johnazrael-ga on 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"---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
going on?


Clarification of Answer by maniac-ga on 11 Oct 2005 18:25 PDT
Hello Johnazrael,

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).

johnazrael-ga rated this answer:5 out of 5 stars and gave an additional tip of: $15.00
Thanks for all your help. Great work and fast response. This was my
first time using and I am quite happy with the result.

There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy