However, since you are not familiar with rewrite, you have made the following adjustments and created a bunch of folders manually:
This directory structure is quite troublesome to maintain. Each time you add a new page, you need to open a folder.
In fact, we use the structure on the left to deploy the service. If the server is slightly set, we can support the desired URL effect.
How to play rewrite
First, check whether your server supports. htaccess.
If this product is supported, you do not need to restart the server every time you write a rule to facilitate testing.
Http://uicss.cn/redirect301/test.htm/
If it succeeds, your access to xxx.com/test.htmwill automatically jump to my blog.
If it fails, you need to enable. htaccess:
Open confhttpd. conf, find # loadmodulerewrite_module, remove #, and load this module.
Open the confextrahttpd-vhosts.conf, find allowoverridenone, and change none to all
After the environment is ready, you also need to read the rewrite interpretation of the special characters in "pattern matching:
* Represents the first 0 or more characters
+ Represents the first 1 or more characters
? Represents the first 0 or 1 Character
^ Represents the start position of the string
^ Represents "not" in square brackets. For example, [^/] represents a non-Slash.
$ Indicates the position at which the string ends.
. Represents any character (that is, a wildcard)
Remove the special meanings of the following characters and convert them to original characters.
-- This part of understanding comes from the end of chapter 6 of Seo art.
Start. Open rewrite of. htaccess.
Rewriteengineon
Replace xxx.htm with xxx/
Rewriterule ^ (. *)/$/define 1.htm [l]
Add another example, replace the xxx.php file on the server with xxx.html
Rewriterule ^ (. * pai.html $/$ 1.php[ L]
More methods:
Allow all users accessing www.test.com/xxx/to access test.com/xxx/
Rewritecond % {http_host} ^ test.com [Nc]
Rewriterule ^ (. *) $ http://uicss.cn/4101l,r%301]
Code for enabling redirection for a specified directory:
Rewritebase/top/
Redirection with search parameters:
Rewriterule ^ search/(. + )? $/Index. php? S = $1 [QSA, l]
Slash At the end of the directory:
Rewriterule ^ (. + [^/]) $/$1/[R]