I am trying to set a simple replacement in my URL query strings.
I have an absolute path in my query string I would like to be replaced by a custom string.
FROM http://acme.com/a/path?file=DIR/this.file&foo=2
TO http://acme.com/a/path?file=/long/absolute/path/to/this.file&foo=2
These are my directives:
# [sudo a2enmod rewrite]
RewriteCond %{QUERY_STRING} ^(.*)file=DIR(.*)$
RewriteRule ^/a/path /a/path?%1file=/long/absolute/path/to%2
With such a configuration, replacement does not work, DIR
passes through.
I configured a LogLevel
to trace1
in my Apache2 configuration but I get nothing in my access.log
and no useful feedback in error.log
.
The question is:
References:
答案 0 :(得分:1)
这对我有用(我已经添加了标志R和L):
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(.*)file=DIR(.*)$
RewriteRule ^/a/path /a/path?%1file=/long/absolute/path/to%2 [R,L]