This %{QUERY_STRING} ^(.*)/teste(.*)$
check if you have /test
in QUERY_STRING
, something like http://localhost/foo/bar?foo=/test
, is that right what you want? Now if the goal is to reach the URL this is wrong.
Another detail, probably the sign of ^
in front of ^/parcerias/teste.html
this wrong, this sign is for regex, and there is regex is the destination path only, so remove it, should stay like this:
RewriteRule ^(.*)$ /parcerias/teste.html
I believe you want it to be REQUEST_URI
to verify the PATH (path in URL):
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)/teste(.*)$
RewriteRule ^(.*)$ /parcerias/teste.html?utm_source=teste&utm_medium=site&utm_campaign=parcerias [R=302,L]
Or simply apply to RewriteRule
:
RewriteEngine On
RewriteRule ^(.*)/teste(.*)$ ^/parcerias/teste.html?utm_source=teste&utm_medium=site&utm_campaign=parcerias [R=302,L]
Of course this will probably cause a loop, since the redirected URL also has /teste
in /parcerias/teste.html
, you probably want otherwise to prevent redirect if it is already in a URL with /teste
, then what you want is a condition of not contain /teste
, in this case just use the !
, thus:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(.*)/teste(.*)$
RewriteRule ^(.*)$ /parcerias/teste.html?utm_source=teste&utm_medium=site&utm_campaign=parcerias [R=302,L]
This
%{QUERY_STRING} ^(.*)/teste(.*)$
check if you have/test
in Query_string, something likehttp://localhost/foo/bar?foo=/test
, is that right what you want? Now if the goal is to reach the URL this is wrong.– Guilherme Nascimento
I want http://localhost/test < to check this, after the base url of the site check if it has the test value.
– Gustavo Souza
How would I get the value after the base url and replace?
– Gustavo Souza
So QUERY_STRING doesn’t make sense, because it checks the contents of querystring as
?foo=bar
and not the PATH.– Guilherme Nascimento
I’m creating an answer.
– Guilherme Nascimento
Oh yes, I seem to understand what you mean, okay I’m waiting
– Gustavo Souza
I posted an answer, but I’m not sure what you want, test the code and if it doesn’t work explain what the goal is so I can edit the answer within your need.
– Guilherme Nascimento
It plays a value before the url, would know the pq of it?
%5e/parcerias
– Gustavo Souza
Gustavo edited the answer, probably the sign of
^
in front of^/parcerias/teste.html
this wrong, this sign is for regex, and there is regex is the destination path only, so remove it,– Guilherme Nascimento
Oops, it worked. Thank you very much!
– Gustavo Souza