Today, the Local debugging PHP program, the use of the. htaccess, and the default configuration inside. htaccess, found on the Internet to open. htaccess, a feasible way for friends to learn from. (Open my His method not, look up a bit allowoverride none of all to replace allowoverride all on, the reason is unknown, O (∩_∩) o~ Remember to change after the httpd.conf must restart the Apache only Oh ~)
1. How to get the local Apache. htaccess How to get the local Apache ". What about htaccess"? In fact, as long as the simple change of Apache httpd.conf settings let apache.htaccess, to see the operation
Open the httpd.conf (there?) Apache Directory of the Conf directory inside), with a text editor open, find
(1)
Options FollowSymLinks
AllowOverride None
To
Options FollowSymLinks
AllowOverride All
(2) Remove the following note LoadModule Rewrite_module modules/mod_rewrite.so
That's it.
2. htaccess A. htaccess (or "Distributed Configuration") in Apache that configures the configuration for a directory by placing the containing or multiple directives in a specific document directory for this directory and its subdirectories. As, the commands that can be restricted. Apache's allowoverride instruction to set.
The instructions in the subdirectory will be in the higher-level directory or in the host configuration.
. htaccess must be uploaded in ASCII mode, preferably with the permissions set to 644.
Locating the wrong document
Common client-side begging error return code:
401 Authorization Required
403 Forbidden
404 Not Found
405 Method Not allowed
408 Request Timed out
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type
Common error return code for the device: Internal Server Error
Use. htaccess to specify a previously crafted Error reminder page. In general, people specialize in setting up directories, such as errors to place pages. And then again. htaccess, add the following instructions:
A single line of instructions. The first instruction above means that for 404, also find the document to display the page is the/errors directory of the notfound.html page. It is not difficult to see that the grammatical pattern is:
With very few prompts, there is no need to make a page that is directly HTML in the instruction, such as the following example:
ErrorDocument 401 "You have access to this page, please give up!" ”
password protection for document access
To use. htaccess to set access and corresponding passwords to a document in a directory, the first thing to do is to generate a. htpasswd text document, for example:
Zheng:y4e7ep8e7eyv
Here the password is encrypted, and some tools are found to encrypt the password into the. htaccess code. This document is best not to be placed in the WWW directory, it is recommended to be placed outside the WWW root document, which is more secure.
With the authorization document, add the following directive to the. htaccess:
Directory of AuthUserFile. htpasswd
Authgroupfile/dev/null (Directory authorized to access)
AuthName Enterpassword
AuthType Basic (Authorization type)
Yes, the master, should be everywhere for the sake. --Lei Feng
Require user wsabstract (Allow access, hopefully the table is allowed, require Valid-user)
Note, parentheses Department for learning to add notes
Deny access from an IP
I do not want a government department to visit the site, that. htaccess to join the department's IP and reject them outside.
For example:
Order Allow,deny
Deny from 210.10.56.32
Deny from 219.5.45.
Allow from all
The second line rejects an IP, the third line rejects an IP segment, and 219.5.45.0~219.2.45.255
Want to reject people? With the Deny from all. Not only with IP, but also with the domain name to set.
protect. htaccess documents
When. htaccess to set the password protection for a directory, it contains the path to the password. From a security point of view, it is necessary to protect the htaccess, and not let others see it. Although using other to do this, like the permissions of the document. But, htaccess itself can do so simply by adding the following instructions:
Order Allow,deny
Deny from all
URL Steering
You may have relocated the document, or changed the directory. This, access from search engines or other links can make mistakes. In this case, the following instructions are used to complete the old URL automatically to the new:
Redirect/old directory/old document name new document
or the entire directory of the steering:
Redirect Old Directory New directory
Change the default home page
In general, the default home name has default, index and so on. However, some directories do not have a vacancy in the province, but a particular name, like in the PmWiki is pmwiki.php. In this case, it is troublesome to remember the name to visit. Set a new default name in the. htaccess:
DirectoryIndex the new default name
Also lists several, in order to indicate the priority level between them, for example:
Do not like others on the Web page connected, document words, but also htaccess instructions to do.
The instructions are as follows:
Rewriteengine on
Rewritecond%{Http_referer}!^$
Rewritecond%{http_referer}!^http://(www.) mydomain.com/.*$ [NC]
Rewriterule. (gif&line;jpg) $-[F]
Feel that let someone else's page open a skylight is not good-looking, then use a piece to replace:
Rewriteengine on
Rewritecond%{Http_referer}!^$
Rewritecond%{http_referer}!^http://(www.) mydomain.com/.*$ [NC]
Rewriterule. (gif&line;jpg) $ http://www.mydomain.com/substitution name [r,l]
Other Supplements: Before giving how to configure Apache support. htaccess files, let's first state that using the. htaccess file can degrade a bit of performance on the httpd server.
Configuration method
Locate Apache's httpd.conf configuration file, and the editor opens.
Found it
<directory/>
Options FollowSymLinks
AllowOverride None
</Directory>
Amended to
<directory/>
Options FollowSymLinks
AllowOverride All
</Directory>
It's okay.
/*
If you need to use a filename other than. htaccess, you can change it with the Accessfilename directive.
For example, if you need to use. config, you can configure it in the server configuration file in the following ways:
*/
Accessfilename. config typically, the. htaccess file uses the same configuration syntax as the primary configuration file. The allowoverride directive determines, by category, which instructions in the. htaccess file are valid.
(not) use of. htaccess files
In general, you should not use the. htaccess file unless you do not have access to the primary configuration file. There is a very common misconception that user authentication can only be achieved through the. htaccess file, it is not so, the user authentication written in the main configuration file is completely feasible, and is a good way.
The. htaccess file should be used in cases where the content provider needs to change the server configuration for a particular directory without root permissions. If your server administrator does not want to modify the configuration frequently, you can allow users to modify the configuration themselves through the. htaccess file, especially if the ISP is running multiple user sites on the same machine, and you want users to be able to change their configuration.
However, you should generally avoid using. htaccess files as much as possible. Any configuration you want to put in the. htaccess file can be placed in a section of the main configuration file and more efficient.
There are two main reasons to avoid using. htaccess files.
The first is performance. If the. htaccess file is enabled by allowoverride, Apache needs to find the. htaccess file in each directory, so whether or not it is actually used, enabling. Htaccess can cause performance degradation. In addition, for each request, a. htaccess file needs to be read once.
Also, Apache must find the. htaccess file in all superior directories so that all valid directives work, so if you request a page in/ctusky/ctu/sky, Apache must look for the following files:
/.htaccess
/ctusky/.htaccess
/ctusky/ctu/.htaccess
/ctusky/ctu/sky/.htaccess a total of 4 extra files to visit, even if none of these files exist, which is why this article began to affect a bit of performance on the server.
The second is security. This allows the user to modify the server's configuration on their own, which may lead to some unexpected changes, so please seriously consider whether you should give the user such privileges.
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.