Let Apache support rewrite static page rewriting methods _linux

Source: Internet
Author: User
First determine which Apache version you are using, and whether the Mod_rewrite module is loaded.

Users of Apache 1.x please check the conf/httpd.conf for the following two pieces of code:

LoadModule rewrite_module libexec/mod_rewrite.so addmodule mod_rewrite.c

Apache 2.x users please check the conf/httpd.conf for the following code: LoadModule rewrite_module modules/mod_rewrite.so

If so, add the following code to the configuration file (httpd.conf). It is important to note that if a Web site is defined by a virtual host, it must be added to the virtual host configuration, i.e., if it is added outside the virtual host configuration, it may not be available. Change and then restart Apache.

After confirming that the Mod_rewrite module is turned on, for the virtual host user, you can also create a. htaccess file to achieve the purpose of URL rewriting, and the first to be set up in the Site directory to open allowoverride all (default is allowoverride None);

The contents of the. htaccess file are as follows # Rewriteengine mode open rewriteengine on # Modify the/dir in the following statement for your site directory address, if the program is placed in the root directory, please change/dir to/rewritebase /dir # Rewrite Modify the corresponding system rules
Rewriterule ^archiver/((Fid|tid)-[\w\-]+\.html) $ archiver/index.php?$1
Rewriterule ^forum-([0-9]+)-([0-9]+) \.html$ forumdisplay.php?fid=$1&page=$2
Rewriterule ^thread-([0-9]+)-([0-9]+)-([0-9]+) \.html$ viewthread.php?tid=$1&extra=page\%3d$3&page=$2
Rewriterule ^space-(Username|uid)-(. +) \.html$ space.php?$1=$2 rewriterule ^tag-(. +) \.html$ tag.php?name=$1 will create a good. htaccess file in the appropriate directory, this time can support URL static address, convenient search engine crawling

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.