Rewritecond Apche get URL parameters

Source: Internet
Author: User
Used in the development system:

Rewriteengine onrewritecond % {QUERY_STRING} SER = ([a-zA-Z0-9 _] +) rewriterule ^/engine (. *) $ http://e.smartearth.cn: 9000/% 1? % {QUERY_STRING} [p] rewritecond % {QUERY_STRING} SER = ([a-zA-Z0-9 _] +) rewriterule ^/([a-zA-Z0-9 _] +)/engine (. *) $ http://e.smartearth.cn: 9000/% 1? % {QUERY_STRING} [p]

Or

Rewritecond % {QUERY_STRING} ^ .*&? SER = ([a-zA-Z0-9 _] + )&?. * $
Rewriterule ^/engine $ http://e.smartearth.cn/%1

Rewritecond % {QUERY_STRING} ^ .*&? SER = (\ W + )&?. * $
Rewriterule ^/engine $ http://e.smartearth.cn/%1

Matched

Http://engine.smartearth.cn/smartearth_engine_Ser/engine? St = localsearch & City = % C8 % AB % B9 % fa & words = % B3 % D4 % B7 % B9 & SER = se_ls & uid = xxxxhttp: // engine.smartear.cn/engine? St = localsearch & City = % C8 % AB % B9 % fa & words = % B3 % D4 % B7 % B9 & SER = se_ls & uid = xxxx

Direction:
Http://e.smartearth.cn: 9000/se_ls? St = localsearch & City = % C8 % AB % B9 % fa & words = % B3 % D4 % B7 % B9 & SER = se_ls & uid = XXXX Conversion

The following are some of my excerpts on rewritecond:

Like the if statement in our program, rewritecond indicates executing the rewriterule statement next to rewritecond if one or more conditions are met. This is the original and basic function of rewritecond, for ease of understanding, let's take a look at several examples.
Rewriteengine on
Rewritecond % {http_user_agent} ^ Mozilla \/5 \. 0 .*
Rewriterule index. php index. M. php
 
Rewritecond % {http_user_agent} ^ lynx .*
Rewriterule index. php index. L. php

Rewriterule index. php index. B. php
The purpose of the preceding statement is to use the FF browser to access the index. the PHP file will automatically allow you to access the index. m. PHP file. When you use some mobile terminals to access the file, you will be directed to the index. the actual access to the PHP file is index. l. if you use another browser to access PHP, you will be redirected to index. b. PHP. In terms of image, the above statement is equivalent to the following statement in the Program (taking the PHP statement as an example ):
If ($ _ server [\ 'HTTP _ user_agent \ '] = \ 'mozilla/5.0 \')
{
// Jump to the access to index. M. php
}
Else if ($ _ server [\ 'HTTP _ user_agent \ '] ==\ 'lynx \')
{
// Jump to access index. L. php
}
Else
// Jump to access index. B. php
 
See example 2:
Rewritecond % {http_referer} (www.test.cn)
Rewriterule (. *) $ test. php
The purpose of the preceding statement is that if the host address of the previous page you access is www.test.cn, the access to test. php will be redirected no matter which page you are currently accessing.

See example 3:
Rewritecond % {remote_host} ^ host1. * [or]
Rewritecond % {remote_host} ^ host2. * [or]
Rewritecond % {remote_host} ^ host3 .*
Rewriterule (. *) $ test. php
The purpose of the preceding statement is to jump to test. php if your address is host1, host2, or host3. It can be seen from this that the default and between the rewritecond statements is, if you want or, you need to write it clearly.

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.