Typically, the rewrite rules are written in the. htaccess file when the URL is rewritten using the Apache rewrite module. But to enable Apache to read the contents of the. htaccess file properly, you must configure the. htaccess directory. From security considerations, the allowoverride properties of the root directory are generally configured to disallow No Override, that is,
The code is as follows |
Copy Code |
< Directory/> AllowOverride None </directory> |
When AllowOverride is set to None, the. htaccess file is completely ignored. When this directive is set to all, all directives with the ". htaccess" Scope are allowed to appear in the. htaccess file.
For URL rewrite, you need to set the directory at least
The code is as follows |
Copy Code |
< directory/myblogroot/> AllowOverride FileInfo </directory> |
2. Enable the Options followsymlinks and allowoverride all in directories to support URL Rewirte
The code is as follows |
Copy Code |
alias/php "c:/web/php/" <directory "c:/web/php/" > Options Indexes FollowSymLinks AllowOverride All Order Allow,deny Allow from all </Directory>
|
When this is accessed through http://localhost:8080/php/, the/php/and the subdirectories underneath it will support the URL rewrite
1 authconfig allows all permission commands to be used, including Authdbmgroupfile Authdbmuserfile authgroupfile authname authtypeauthuserfile and require
2 FileInfo allows the use of file control type directives. They include addencoding addlanguage addtype defaulttype errordocument languagepriority
3 Indexes allows the use of directory control type directives. They include adddescription AddIcon addiconbyencoding addiconbytype defaulticon directoryindex FancyIndexing HeaderName Xignore indexoptions Readmename
4 Limit allows permission control instructions to be used. They include allow deny and order
5 options allow you to use instructions that control the directory features. They include Options and Xbithack.
Options
1 All functions except multiviews are permitted below
2 MultiViews allows multiple content to be browsed, if your directory has a file called Foo.txt, then you can visit it through/foo, which is more useful for a multilingual content site
3 Indexes If there is no index file in the directory, you are allowed to display the files in the directory for selection
4 IncludesNOEXEC allows SSI, but cannot use #exec and #include functions
5 Includes allows SSI
6 followsymlinks In this directory, the server will track symbolic links. Note that even though the server tracks symbolic links, it does not change the pathname used to match different areas, and if set within the <Local>; tag, this option is ignored
7 SymLinksIfOwnerMatch in this directory to track only the links within this site
8 execcgi is allowed to use CGI under this directory