Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help Forums Windows Startup Programs Database Virus, Spyware, and Malware Removal Guides Computer Tutorials Uninstall Database File Database Computer Glossary Computer Resources
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

 
Reply to this topicStart new topic
> How To Use The .htaccess File To Redirect Users
nosnhoj#3
post Jun 23 2006, 08:52 PM
Post #1


Forum Regular
***

Group: Members
Posts: 245
Joined: 27-May 05
From: 127.0.0.1
Member No.: 21,516



How To Use The .htaccess File To Redirect Users



Guide Overview

The purpose of this guide is to teach you how to use the .htaccess file to redirect users to pages that you have modified, deleted, or moved. The .htaccess file is associated with Apache Servers. Not all web hosting services allow modification of this file. Before following this guide, contact your web hosting service provider to confirm that addition and/or modification to this file is allowed.


Instructions
  1. Access your site using the method you normally use to implement changes, and determine whether or not your directory includes a file named .htaccess
  2. If it does, open the file in the text editor of choice. (If so, Skip to step 5)
  3. If it does not, you will need to create one, and upload it to the Root Directory of your site. To do this, open up Notepad or your preferred text editor.
  4. Click File ---> Save as...
    In Notepad, change the Save as type to All Files. Give your file the name .htaccess (the period "." before htaccess is required) and save it to the directory of your choice. Close the file.
  5. Now, open the .htaccess file with the text editor of your choice, and in one complete line, enter the commands for your desired effect, with a space between each command:

    The redirect command has the following format: redirect status /old/old.html http://www.new.com/new.html
    - "Status" is optional and may be one of the following:

    permanent or 301 resource has moved permanently.
    temp or 302 resource has moved temporarily.
    seeother or 303 resource has been replaced.
    gone or 410 resource has been permanently removed. (When this status is used the new-url argument should not be used.)

  6. Save the file, and depending on if it previously existed in the web directory or if you created it, update your site.

    NOTE: If you created the file, it is important that you upload the file to the Root Directory of your site, which is the directory where your default "index" or "home" page resides.


Redirection Notables

1. Be sure not to add "http://www" to the first part of the statement - just put the path from the top level of your site to the page. Also ensure that you leave a single space between these elements:

redirect 301 (the instruction that the page has moved)

/old/old.html (the original folder path and file name)

http://www.new.com/new.html (new path and file name)

2. Each page being redirected needs to occupy it's own line in the .htaccess file.

Conclusion

Be sure to test out your changes after you make them. If something does not work as intended, delete the entry, so it does not create any further problems, and refer to your web host for answers.


--------------------
When I'm right, I'm right....
And when I'm wrong, I could have been right....
So I'm still right, cause I could have been wrong.
Go to the top of the page
 
+Quote Post
Wendy K. Walker
post Oct 28 2007, 11:45 PM
Post #2


Senior Member
****

Group: Members
Posts: 567
Joined: 28-June 05
From: 300 Yards behind you, tracking you with a sniper scope
Member No.: 25,107



Hi nosnhoj#3,

This seems to be a pretty well written and informative 'howto' that you have here. I am toying around with an Apache web server and this seems to be something that I need to learn more about.

Up until a couple of days ago I didn't have a .htaccess file. Then while perusing an article on securing a server with a password I decided to give it a go and see what that was all about. I followed the instructions that were given to create a password file, htpasswd, and by the time that I had gotten through I had created both a htpasswd, and a .htaccess file.

The .htaccess file looks like this -->

AuthType Basic
AuthName "WARNING!This Is A SECURE AREA, PLEASE LOG IN"

AuthUserFile "c:\Documents and Settings\ADMIN\my_password_file.txt"
AuthGroupFile /dev/null

<Limit GET POST PUT>
require valid-user
</Limit>

That sucker worked too tongue.gif , it made me have to sign in! But that's all that's in it at the moment. Do I just add more lines to make it redirect people to different pages?

OK, now I'm trying to figure out where to put it. According to the way that I'm understanding this -->

NOTE: If you created the file, it is important that you upload the file to the Root Directory of your site, which is the directory where your default "index" or "home" page resides. <--

Then my path to that file should look something like this --> C:\Program Files\Apache Group\Apache2\htdocs\.htaccess <-- right? I mean because that's where the default index thingy is.

Thanks for any insight Boo.

♥ Wendy


--------------------

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 21st November 2009 - 09:15 PM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Virus Removal Guides

© 2003-2009 All Rights Reserved Bleeping Computer LLC.