I've modified the below to suit my needs... what does %1 do? Any difference from $1?
$
n is from the RewriteRule. %
n is from the last RewriteCond (that creates backreferences/variables).
The Apache web server that I'm doing the mod rewrite has a plugin module that redirects traffic to an application server. Wonder if the second part of the rewrite rule will cause it to fail?
If you add the PT (Pass Through) flag (replace [QSA,L] with [QSA,PT,L]) the other module should be processed as well.
I need to implement the second requirement first, so I added the below code into the web server httpd.conf. However, when I accessed
http://www.example.com/index.html, it is also redirected. Shouldn't it be caught by the first rewrite condition as it is an existing filename? I expect to see the contents of index.html.
My mistake, in the httpd.conf file %{SCRIPT_FILENAME} does not contain the document root. You need
- Code: Select all
%{DOCUMENT_ROOT}%{SCRIPT_FILENAME}
instead of just
- Code: Select all
%{SCRIPT_FILENAME}
What does QSA mean?
Query String Append. If you request /jkl?
mno=pqr it would rewrite to /abc/def?type=jkl&
mno=pqr. Without it it would go to /abc/def?type=jkl. More
information about RewriteRule flags.My code only worked when I used [R=301,L] in place of that as the redirected page is in the application server.
The PT flag should sort that.