Hdwiki Encyclopedia Construction Station Lecture Phase III: Rewrite rules under Apache and IIS

Source: Internet
Author: User
Keywords Lecture

Intermediary transaction SEO diagnosis Taobao guest Cloud host technology Hall

Everyone good, "Hdwiki Encyclopedia building Station Lecture III" now officially started ~ ~, today, invited to our guest is Li Guang Ming (forum Id:wanner), he will be "Apache, IIS under the rewrite rules" of the topic and you webmaster friends to communicate, below, With warm applause please Wanner

1, pseudo-static introduction

Pseudo-Static is: Dynamic Web page by rewriting the URL method to remove dynamic page parameters, but in the actual page directory does not need to implement the existence of overridden pages.

Pseudo static Purpose

The main thing is to cater to search engine convenience search engine spiders (Spider) to crawl the relevant content on the page! Easy access to Web sites A good web page if the user in the dynamic communication between the feelings of mutual trust will not be high but a look at a static page relative to the user's trust on the Web page is higher and the pseudo static suffix way basically similar to a look at it is a static or a true Web page! Pseudo-static SEO benefits, included than dynamic will be better.

2, set pseudo static requirements

Set pseudo static requirements, different server requirements, Apache needs rewrite module, IIS need to install Isapi_rewrite software. (If the virtual host, can be consulted to the space business), independent host can be set up, the general Apache default will have rewrite module and open, if not open, you can open the Apache configuration file httpd.conf file, LoadModule Rewrite_ Module modules/mod_rewrite.so, remove the front well number and maintain the restart Apache to talk about the IIS Isapi_rewrite software.

L Select the Web site in IIS Manager, and right click on Properties, as shown in

  

L Select your site, for example, the default site, right click, select Properties, such as Figure two

  

L View ISAPI Filters

  

L Add an ISAPI filter, the isapi.dll you want to select can be downloaded online

  

  

  

L Determine if you have just added success

  

When the green up arrow when the state is added successfully, when the rewrite environment is configured to open the rewrite.

3, open pseudo static

When confirmed that the rewrite module has been installed, you can open the Hdwiki background rewrite rules, Apache users will not normally have any problems, the system has been automatically generated. htaccess file, IIS users need to manually add Httpd.ini files in the forum directory (virtual host users can consult the space provider where the file exists), specific reference http://kaiyuan.hudong.com/bbs/viewthread.php?tid=10341 &extra=&highlight=iis%2b&page=1, this is the 4.0.5 rule, but this is a general rule, 4.1 also apply, if you want to write out the rules, can refer to http:// Kaiyuan.hudong.com/bbs/viewthread.php?tid=13330&highlight=rewrite

4, rewrite rules

hdwiki4.1 's manual contains rewrite rules for Apache,iis and Nginx three servers

L The rules under Apache

Rewriteengine on #表示开启rewrite

rewritebase/hdwiki4/wikiframe/#设置目录级重写的基准URL, refers to the path of the site

Rewritecond%{request_filename}!-f #RewriteCond是指定义重写发生的条件, which means that a rewriterule can have multiple rewritecond in front of it, that is, when conforming to Rewritecond ,%{request_filename} represents the file name of the request! Represents a regular file that is not---F, which indicates that the requested file name is resumed when it is a rewriterule file, otherwise it is not executed (when the regular file refers to A.txt), Files that can be downloaded directly)

This rule is enforced by Rewritecond%{request_filename}!-d #该句表示请求的文件名不是一个目录继续执行RewriteRule ^.*$ index.php?$0 #当上面两个条件都符合了, which means, for example, ABC will be directed to INDEX.PHP?ABC

In the above code, there are a lot of regular expressions, Rewriterule ^.*$ index.php?$0 as an example of what to begin with, for example, the ^A expression begins with a character, '. ' The word Fu Shitong, which denotes any character, * represents the preceding expression 0 to N,. * represents 0 or N arbitrary characters, $ indicates what ends, b$ represents all characters with a B-character ending $ for matching. Look at this instance again.

Rewriterule ^/wiki/(. *) $/index\.php\?doc-innerlink-$1

This inside has the ^/wiki/(. *) $ this inside bracket matches the string, if also has the parentheses, is the $2$3....iis rewrite rule basically and this, the ISAPI high version compatible with the above wording, the specific reference manual, moreover should note that, Many IIS users write the rules of Hdwiki and other systems such as Discuz, causing IIS to conflict, which can typically be distinguished by folder names

For example, some users write this in Httpd.ini

Rewriterule ^/(. *)/(. *) \. (htm|html|shtml|tpl|asp|jsp|php|do) $/baike/index\.php\?$1 can be changed to Rewriterule ^/baike/(. *) \. (htm|html|shtml|tpl|asp|jsp|php|do) $/baike/index\.php\?$1 There are a lot of users IIS is not used in this generic writing, but with the same written as DZ is specific, such as Rewriterule ^/ baike/doc-view-(. *) $/baike/index\.php\?doc-view$1 This type of writing can be completely, the only inconvenient is that if the hdwiki in the newly added features, this URL may not be resolved, Because there is no corresponding rule, we can follow the gourd to write a scoop on the

L Nginx

if ($request _filename!~* (. *) \. ( Css|js|gif|jpg|png|xml)) {

# Modify the/hdwiki in the following statement for your Hdwiki directory address, if the program is placed in the root directory, please change/hdwiki to/

Rewrite ^ (/hdwiki)/(. *) $ $1/index.php?$2;

}

To open only the rewrite rule with the http://mydomain/entry name, add the following code:

# Modify the/hdwiki in the following statement for your Hdwiki directory address, if the program is placed in the root directory, please change/hdwiki to/

Rewrite ^ (/hdwiki)/wiki/(. *) $ $1/index.php?doc-innerlink-$2 last;

Rewrite rules for other servers are expressed in regular expressions with a slightly different style

For example, LIGHTTPD is written as follows (Http://kaiyuan.hudong.com/bbs/viewthread.php?tid=13353&highlight=rewrite)

Url.rewrite = (

"^ (. *) \/(Attachment|category|comment|doc|edition|list|pms|reference|search|synonym|user|plugin|admin|pic|gift) ([^\/]*) $ "=>" $1/index.php?$2$3 "

)

5, pseudo-static shortcomings

A bit larger flow of some use pseudo static CPU overload, because the pseudo static is used to judge rather than the real address, to identify which page is the responsibility of the direct designated by the CPU to judge, so the increase in CPU occupancy, is indeed the biggest fault of pseudo static. But for the traffic is not large, but need to collect the amount of personal sites, pseudo static is a good choice

6, turn off Hdwiki pseudo static

When pseudo static is not normal to use, some users can not normally log in to the background to turn off pseudo static, the new patch to ensure that the rewrite pseudo static can also log on, can download 4.1 of the patch package for no upgrades or no patching of the students can not log in, you may use the Toolbox landing

Host:

Thanks for the bright answer, this lecture is over.

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.