Using rewrite to implement Discuz pseudo-static configuration under Apache

Source: Internet
Author: User

Apache implementation of Discuz pseudo-static configuration using rewrite

1, pseudo-static introduction and function

pseudo-Static is relative to the real static, usually we want to enhance Search Engine friendly side, the article content is generated static pages, but some friends in order to display some information in real time. Or you want to use dynamic scripting to solve some problems. You cannot display site content in a static manner. But this loses the friendly side of the search engine. How to find a middle method between the two, which produces pseudo-static technology. is displayed in the form of a static page of HTML, but in fact, the ASP or PHP and other dynamic scripts to deal with.

2,RewriteImplementDiscuzpseudo-static configuration steps(1) configuration Step text description

First login Discuz admin, go to "Admin Center" > "Global" > "Optimize Configuration" > "Search Engine Optimization (SEO settings)", then the URL address want to static page list place tick, then click Submit.

(2The detailed implementation steps are as follows

1 , access to the management center

2 , enter the password for the user name, and then submit.

3 , enter the password above to enter the following interface, click the global >seo settings.

4 , select the page list where you want the URL address to be static, and click Submit.

5 , click " View current Rewrite rules " After the above settings are complete.

6 , click on the above to view the current rewrite rules, the following page will appear, the corresponding user rules copied into the Apache Web Services configuration file, and then restart the service to achieve dynamic page pseudo static configuration.

(3)ApacheService Standalone Host user useRewriteConfiguring pseudo-static

Modify the Apache master configuration file and add the following in the configuration file

vim/usr/local/apache2/ conf/httpd.conf

<ifmodule mod_rewrite.c>

Rewriteengine on

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/topic-(. +) \.html$ $1/portal.php?mod=topic&topic=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/article-([0-9]+)-([0-9]+) \.html$ $1/portal.php?mod=view&aid=$2&page=$3&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/forum-(\w+)-([0-9]+) \.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/thread-([0-9]+)-([0-9]+)-([0-9]+] \.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page \%3d$4&page=$3&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/group-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=group&fid=$2&page=$3&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/space-(USERNAME|UID)-(. +) \.html$ $1/home.php?mod=space&$2=$3&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/blog-([0-9]+)-([0-9]+) \.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/(Fid|tid)-([0-9]+) \.html$ $1/archiver/index.php?action=$2&value=$3&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (. *)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+) \.html$ $1/plugin.php?id=$2:$3&%1

</IfModule>

(4)ApacheVirtual Host user useRewriteConfiguring pseudo-static

Modify the Apache virtual Host configuration file and add the following in the configuration file

Vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

# Open the Rewriteengine mode

Rewriteengine on

# Modify the/discuz in the following statement as your forum directory address, if the program is placed in the root directory, modify the/discuz to/

Rewritebase/discuz

# Rewrite System rules do not modify

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^topic-(. +) \.html$ portal.php?mod=topic&topic=$1&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^article-([0-9]+)-([0-9]+) \.html$ portal.php?mod=view&aid=$1&page=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^forum-(\w+)-([0-9]+) \.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^thread-([0-9]+)-([0-9]+)-([0-9]+] \.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3d$3 &page=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^group-([0-9]+)-([0-9]+) \.html$ forum.php?mod=group&fid=$1&page=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^space-(Username|uid)-(. +) \.html$ home.php?mod=space&$1=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^blog-([0-9]+)-([0-9]+) \.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ (Fid|tid)-([0-9]+) \.html$ archiver/index.php?action=$1&value=$2&%1

Rewritecond%{query_string} ^ (. *) $

Rewriterule ^ ([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+) \.html$ plugin.php?id=$1:$2&%1


Using rewrite to implement Discuz pseudo-static configuration under Apache

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.