Home >Backend Development >PHP Tutorial >Parsing htaccess pseudo-static rules_PHP tutorial

Parsing htaccess pseudo-static rules_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:06:06939browse

Using htaccess files can make the site pseudo-static, and the target address formed is almost exactly the same as a real static page, such as wangqu.html, etc. Pseudo-static can be combined with SEO to improve the ranking of the site, and also It can give people an impression of stability.

Since pseudo-static must be set completely according to different sites, we can only briefly introduce its principles and give several examples of commonly used programs:

To use pseudo-static through htaccess, the space must support the Rewrite module, which is responsible for URL rewriting. Otherwise, even if it is set up, it will not be able to be used, and a 500 error may occur.

The following is the pseudo-static setting text of Discuz:

# Turn on RewriteEngine mode
RewriteEngine On
# Do not modify the Rewrite system rules
RewriteRule ^archiver/((fid|tid)-[0-9]+.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

The following is the pseudo-static setting text of Phpwind:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)simple/([a- z0-9_]+.html)$ $1/simple/index.php?$2

In addition, there are many different rules. If you want to formulate pseudo-static rules that apply to your own site, you must be familiar with website structure and regular expressions.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327647.htmlTechArticleUsing htaccess files can make the site pseudo-static, and the target address formed is almost exactly the same as a real static page , such as wangqu.html, etc., pseudo-static can be combined very well...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn