URL rewriting-I think

Source: Internet
Author: User

 

 

 

 

 

 

 

1. URL Builder URL: (do not write regular expressions, which can be generated using the following tools !)

Http://seohelper.cn/tools/urlrewrite

 

Generate two different URL rules based on the written URL (that is, regular expression)

 

 

2. URL rewriting --- Glossary:

The URL is intercepted by the server and parsed. The default rule is DDD. php? Id = 1 & page = 2, ?, & To identify.

 

You can use the. htaccess file in the web root directory to rewrite the file. The principle is that when you access the file in a URL format, you can rewrite the rule and translate it into DDD. php? Id = 1 & page = 2

The rewrite Mechanism acts as a translation function.

 

 

(Http://www.g4qq.com/user/id/2/) ----------> (rewrite mechanism translation) -----------> (http://www.g4qq.com/user.php? Id = 2)

 

 

The description of the. htaccess file is as follows:

Options + followsymlinks

Rewriteengine on

Rewriterule user-ID-(. *)/. html $ user. php? Id = $1

Rewriterule user/ID/(. *)/user. php? Id = $1

 

Rewriteengine on indicates that the rewrite function is enabled.

Rewriterule:

User-ID-(. *)/. html $ user. php? Id = $1 is a translation rule (regular expression)

User/ID/(. *)/user. php? Id = $1 is also a translation rule

 

If you use the rewrite rule rewriterule user-ID-(. *)/. html $ user. php? Id = $1, which can be accessed at http://www.g4qq.com/user-id-2.html,

Then the URL is intercepted, through the URL rewriting mechanism, converted to http://www.g4qq.com/user.php? Id = 2, which is then parsed by the default Apache rules. This is actually a spoofing,

In the final analysis, is it still converted into a http://www.g4qq.com/user.php? Id = 2.

 

 

3. If you still get confused here, perform the instance first.

 

Generally, all spaces support the rewrite function.

There is a. htaccess file and user. php file under the folder I sent. First, you log on to your blog URL. If your blog

There is a. htaccess file or a user. php file under the web root directory. Back up the files and pass them to the root directory of the website,

Access http://www.g4qq.com/user/id/2/,http://www.g4qq.com/user-id-2.html after completion

Of course, you need to replace g4qq with your website directory. You will find that both websites can be accessed and get the same result. This is the URL rewriting.

Is a kind of deception, their results are the same, are http://www.g4qq.com/user.php? Id = 2.

 

 

 

Note:

The code in the user. php file is simple:

<? PHP

$ Id = $ _ Get ['id']; // obtain the ID in the URL.

Echo $ ID;

Echo "FDFD ";

?>

Get the id value, and then + FDFD,

 

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.