How to enable Apache to support rewrite Static Page Rewriting

Source: Internet
Author: User

First, determine the apache version you are using and whether the mod_rewrite module is loaded.

For Apache 1.x users, check whether the following two sections exist in CONF/httpd. conf:Code:

Loadmodule rewrite_module libexec/mod_rewrite.so addmodule mod_rewrite.c

For Apache 2.x users, check whether the following code exists in CONF/httpd. conf: loadmodule rewrite_module modules/mod_rewrite.so

If yes, add the following code to the configuration file (httpd. conf. Note that if the website is defined by a virtual host, you must add it to the virtual host configuration, that is, in progress. If you add it to the virtual host configuration, it may not be available. After modification, restart Apache.

After the mod_rewrite module is enabled, you can also create. to rewrite the URL, you must first enable AllowOverride all in the site directory (AllowOverride none by default );

. the content of the htaccess file is as follows # enable rewriteengine on in rewriteengine mode # Modify/DIR in the following statement to your site directory address, if the Program is placed in the root directory, change/DIR to/rewritebase/DIR # rewrite to modify the corresponding system rule
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 place the created. htaccess file in the corresponding directory. In this case, the URL static address can be supported for 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.