Split, and someone will reply. We all know that PHP's REQUEST_URI includes the query string, which is equal to the content in the browser's address bar. However, we can see this description in the apache document.
REQUEST_URI
The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as its own variable named QUERY_STRING.
It should be said that the query string is independent in QUERY_STRING, and REQUEST_URI is not included in it, which makes me a bit confused, mainly when I do not know RewriteRule ^ (. *) $ the package does not include query strings, for example I have an old url old.com, someone else accesses the http://old.com/query.php? Name = abc when I want 301 override to http://new.com/query.php? Name = abc
RewriteCond %{HTTP_HOST} !^old\.com$ [NC]RewriteRule ^(.*)$ http://new.com/$1 [R=301,L]
Does $1 mean query. php or query. php? What about name = abc? If the query string is not included, do I need to add % {QUERY_STRING} after $1 }???
Reply to discussion (solution)
Tested
RewriteRule ^(.*)$ http://new.com/$1 [R=301,L]
Is included in QUERY_STRING,
But I still don't know whether the REQUEST_URI package does not include QUERY_STRING, but my problem has been solved.
Now we are just getting started with url rewriting. The apache documentation is good. Although the mod_rewrite function is very powerful, don't expect it to be learned in a day or two.
No one answered, so I had to test it myself. it seems that I couldn't find these basic content on the Internet, and I couldn't understand the basic content in English. the correct one is:
# REQUEST_URI does not contain QUERY_STRING;
# The anchor is processed by a local browser and will not be sent to the server;
# RewriteRule ^ (. *) $ matches {REQUEST_URI}, excluding {QUERY_STRING}. when QUERY_STRING is rewritten, it is automatically added to the end.
# Add at the end of the replacement string? Question mark, indicating that the query string is discarded
# Add? to the end of the replacement string? Id = 1, indicating to append this id parameter in QUERY_STRING. of course, you must add QSA in flag.
No one answered, so I had to test it myself. it seems that I couldn't find these basic content on the Internet, and I couldn't understand the basic content in English. the correct one is:
# REQUEST_URI does not contain QUERY_STRING;
# The anchor is processed by a local browser and will not be sent to the server;
# RewriteRule ^ (. *) $ matches {REQUEST_URI}, excluding {QUERY_STRING}. QUERY_STRING will be rewritten ......
At am, is it all night long? Life is the cost ~
Mod_rewrite won't. if you have time, study it.
It's time to take a break .....
All night? Life is the cost ~
Thank you for your attention and love!