1. First, check whether the rewrite module is installed: Cat httpd. conf | grep rewrite Loadmodule rewrite_module modules/mod_rewrite.so 2. Generate a pseudo-static html connection: (1) generate pseudo-static html Add at the end of the <virtualhost> segment Rewriteengine on Rewriterule/goods(%0-9%%%%%.html/goods. php? Id = $1 [pt] More standard writing: Rewriterule ^ (. *)/goods(%0-9%%%%%.html $1/goods. php? Id = $2 [pt] Simpler Syntax: /Goods (\ D +) \. html/goods \. php \? Id = $1 The first parameter (0-9] +) corresponds to $1, and the second parameter corresponds to $2. Example: Rewriterule/Forum-([0-9] +)-([0-9] +) \. html/Forumdisplay. php? FID = $1 & page = $2 [pt] Test http://www.xxx.com/goods1.html with/goods. php? The content of ID = 1 is the same Finally, replace all links with the configured pseudo-static html address. [Pt]: url, that is, the converted goods31.html corresponds to goods. php? Id = 31 (this parameter is not added by default) [R]: The URL redirection jumps to goods. php when goods31.html is used for access? Id = 31 3. Anti-leech: Rewritecrond % {http_host }! Upkiller.com [R = 301, l] Rewriterule ^ (. *) $ http://www.upkiller.com/warning.html [R = 301, l] Redirect requests not from upkiller.com to the http://www.upkiller.com/ Better practice: Rewritecond % {http_referer }! ^ Http: // (www \.)? Upkiller \. com/. * $ [Nc] Rewriterule \. (MP3 | RAR | jpe | GIF) $ http://www.upkiller.com/warning.jpg [R = 301, l] 4. Anti-Baidu crawler: Rewritecond % {http_user_agent} ^ baiduspider [or] Rewriterule ^ (. *) $ http://www.google.com/[R = 301, l] Convert crawlers from Baidu to Goole |