Explanation of the. htaccess file on Unix and linux servers

Source: Internet
Author: User
Article Title: Detailed description of the. htaccess file on Unix and linux servers. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Htaccess can do a lot of things, including: folder password protection, automatic redirection by users, custom error pages, change your file extension, shield specific user IP addresses, only allow specific IP addresses, stop directory tables, and use other files index file, wait ......

1. Introduction to Introduction

File Name. htaccess property 644 (RW-R? R ?)

Htaccess affects all subdirectories in its directory.

Note that most of the content must be kept within one line. Do not wrap the line. Otherwise, an error may occur.

2. Error Documents Error document

Official document: ErrorDocument Directive

ErrorDocument code document

Example

ErrorDocument 400/errors/badrequest.html

ErrorDocument 404 http: // yoursite/errors/notfound.html

ErrorDocument 401 "Authorization Required"

(Note that if the following content appears, the double quotation marks must be escaped \")

Common HTTP Status Codes

Successful Client Requests

200 OK

201 Created

202 Accepted

203 Non-Authorative Information

204 No Content

205 Reset Content

206 Partial Content

Client Request Redirected

300 Multiple Choices

301 Moved Permanently

302 Moved Temporarily

303 See Other

304 Not Modified

305 Use Proxy

Client Request Errors

400 Bad Request

401 Authorization Required

402 Payment Required (not used yet)

403 Forbidden

404 Not Found

405 Method Not Allowed

406 Not Acceptable (encoding)

407 Proxy Authentication Required

408 Request Timed Out

409 Conflicting Request

410 Gone

411 Content Length Required

412 Precondition Failed

413 Request Entity Too Long

414 Request URI Too Long

415 Unsupported Media Type

Server Errors

500 Internal Server Error

501 Not Implemented

502 Bad Gateway

503 Service Unavailable

504 Gateway Timeout

505 HTTP Version Not Supported

3. Password Protection

Official document: Authentication, Authorization and Access Control

Assume that the password file is. htpasswd.

AuthUserFile/usr/local/safedir/. htpasswd (full path name must be used here)

AuthName EnterPassword

AuthType Basic

Two common verification methods:

Require user windix

(Only allow windix login)

Require valid-user

(All valid users can log on)

Tip: how to generate a password file

Use the htpasswd command (apache)

Create a password file for the first generation

Htpasswd-c. htpasswd user1

Then add new users

Htpasswd. htpasswd user2

[1] [2] [3] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.