What is pseudo-static mod_rewrite?

Source: Internet
Author: User

In the past, pseudo-static is often involved in WordPress, that isMod_rewriteThis term was not very clear at the beginning. I only knew it was used to convert the address to HTML for improved indexing. Today I finally got a good article, what is pseudo-static?Mod_rewrite,
The following is about
Mod_rewriteIntroduction:

First, you must enableMod_rewriteFunction.
Open and edit the httpd. conf file in the Apache/conf folder in the Apache directory in Notepad. Find the following sentence:
# Loadmodule rewrite_module modules/
Mod_rewrite. So
Remove the # sign and change it:
Loadmodule rewrite_module modules/
Mod_rewrite. So
Then find the following sentence in the same file:
AllowOverride none
Change it:
AllowOverride all
Close and save the file. In this way, Apache
Mod_rewriteIs enabled, which is very simple.
Below, I want to use
Mod_rewriteImplement the following URL:
Http://xxx.com/0725.html
Http://xxx.com/0726.html
Http://xxx.com/0727.html
...
The above link shows what happened in the history of July 25, similar to this. This looks beautiful and neat, and looks like HTML is generated. However, their actual addresses are:
Http://xxx.com/index.php? Today = 0725
Http://xxx.com/index.php? Today = 0726
Http://xxx.com/index.php? Today = 0727
...
Now I want to implement index. php? Today = static. The following code is used:
1. htaccess File
Rewriteengine on
Rewritebase/
Rewritecond % {request_filename }! -F
Rewritecond % {request_filename }! -D
Rewriterule ^ ([0-9] +)/. html $/index. php? Today = $1
In bold Chinese, I would like to explain that the other formats are in this format, but I do not understand it now.
[0-9] means that the parameter can only be 0 ~ 9. If you want to include any character, change it:
Rewriterule ^ (. +)/. html $/index. php? Today = $1
Here [0-9] is changed to., which represents any character

 

 

Example

 

 

 

 

After the website is upgraded, you can customize the Link name and directory. The static pages with the extension of .html are all static pages on the frontend website. Now Baidu and Google are included in the previous pseudo static pages. After the website is upgraded, the access volume suddenly decreases a lot, it turns out that the website cannot reach a normal page. It is no wonder that the GG is full of eggs recently. I have been studying how to write it. the htaccess Access access rule has never been successful. It is very depressing. When I got up this morning, I saw rape complaints in the QQ group, which is also the reason why the website cannot be reached. Haha. I was suddenly inspired by this message. Let's take a look at sablog1.6. in the htaccess file, let's take a look at how the previous forwarding rules were written. I just changed it, so I spoke about it and went to the forum to find it. the content of the htaccess rule has been changed, but it is still not successful in the middle, but let me see the hope, and then change it, and finally get it done. Compatible with the URLs previously indexed by search engines. Haha ..

Let's share the following:
# Begin sablog-x
<Ifmodule mod_rewrite.c>
Rewriteengine on

#1.6 of the pseudo-static URLs before the upgrade
Rewriterule ^ show-([0-9] +)-([0-9] +)/. html $ index. php? Action = show & id = $1 & page = $2

# Anti-leech
Rewritecond % {http_referer }! ^ Http://www.samool.com/.#$ [Nc]
Rewritecond % {http_referer }! ^ Http://www.samool.com $ [Nc]
Rewritecond % {http_referer }! ^ Http://samool.com/.#$ [Nc]
Rewritecond % {http_referer }! ^ Http://samool.com $ [Nc]
Rewriterule. */. (JPG | MP3 | RM | WMA | exe | RAR | zip) $
Http://www.samool.com/images/error.gif[R, NC]

Rewritebase/

Rewritecond % {request_filename}-f [or]
Rewritecond % {request_filename}-d
Rewriterule ^. * $-[S = 13]

# Archiving with only months
Rewriterule ^ date/([0-9] {6 })/? ([0-9] + )? /? $ Index. php? Action = article & setdate = $1 & page = $2 [QSA, l]

# No category Paging
Rewriterule ^ page/([0-9] + )? /? $ Index. php? Action = article & page = $1 [QSA, l]

# Category
Rewriterule ^ category/([0-9] + )/? ([0-9] + )? /? $ Index. php? Action = article & cid = $1 & page = $2 [QSA, l]
Rewriterule ^ category/([^/] + )/? ([0-9] + )? /? $ Index. php? Action = article & curl = $1 & page = $2 [QSA, l]

# Archive and Advanced Search
Rewriterule ^ (archives | search | Article | links | about )/? $ Index. php? Action = $1 [QSA, l]

# User registration and login
Rewriterule ^ (register | login )/? $ CP. php? Action = $1 [QSA, l]

# All comments, tag lists, and reference lists are paginated
Rewriterule ^ (comments | tagslist | trackbacks | article )/? ([0-9] + )? /? $ Index. php? Action = $1 & page = $2 [QSA, l]

# Tags
Rewriterule ^ tag/([^/] + )/? ([0-9] + )? /? $ Index. php? Action = article & item = $1 & page = $2 [QSA, l]

# Article
Rewriterule ^ archives/([0-9] + )/? ([0-9] + )? /? $ Index. php? Action = show & id = $1 & page = $2 [QSA, l]

# User
Rewriterule ^ UID/([0-9] + )/? ([0-9] + )? /? $ Index. php? Action = article & uid = $1 & page = $2 [QSA, l]
Rewriterule ^ user/([^/] + )/? ([0-9] + )? /? $ Index. php? Action = article & User = $1 & page = $2 [QSA, l]

# Map Files
Rewriterule sitemap. xml sitemap. php [QSA, l]

# Custom links
Rewriterule ^ ([^/] + )/? ([0-9] + )? /? $ Index. php? Action = show & alias = $1 & page = $2 [QSA, l]

</Ifmodule>
# End sablog-x

 

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.