mod rewrite - RewriteRule in .htaccess and Reverse Proxy -
here problem, i`m struggling few days.
we`ve got domain firstpart.maindomanin.com nad subdomain secondpart.maindomain.com. under first domain there first part of project (based on saas commerce) , second part (under secondpart.maindomain.com) - based on symfony. 2 parts connected through soap services etc.
for firstpart.maindoman.com using cloudflare. we`ve got reverse proxy so: firstpart.maindomain.com/uk/made pointed secondpart.maindomain.com/uk
and (we cant enable cloudflare secondpart.maindomain.com due unrelated issues) want redirect url-s secondpart.maindomain.com/uk firstpart.maindomain.com/uk/made example secondpart.maindomain.com/uk/furniture firstpart.maindomain.com/uk/made/furniture secondpart.maindomain.com/uk/sales firstpart.maindomain.com/uk/made/sales etc. need change domain , add 'made' between language code , rest of url
other need redirect urls firstpart.maindomain.com/uk/furniture firstpart.maindomain.com/uk/made/furniture (add 'made' between language code , rest of url)
and need in htaccess under subdomain secondpart.maindomain.com.
i came with:
rewritecond %{http_host} secondpart.maindomain.com$ [nc] rewriterule ^([a-z]{2,3})(.*)$ http://firstpart.maindomain.com/$1/made$2 [r=301,l]
and url secondpart.maindomain.com/uk/furniture
i`m getting redirection to
http://firstpart.maindomain.com/uk/made/furniture
which fine after redirection there infinite loop (so except changing urls not working)
as turned out http_host both firstpart.maindomain.com/uk/made , secondpart.maindomain.com/uk same , secondpart.maindomain.com condition not working. came condition
rewritecond %{request_uri} !^made [nc] rewriterule ^([a-z]{2,3})(.*)$ http://firstpart.maindomain.com/$1/made$2 [r=301,l]
so condition not met if there word 'made' inside uri , in case same in first rule.
i tried several different configurations nothing working.
when tested http://htaccess.madewithlove.be/ fine , there not redirection.
so im assuming there reverse proxy on cloudflare.
im not expert in htaccess tried lot of solutions , nothing working.
i appreciate it.
p.s. in case here .htaccess
<ifmodule mod_rewrite.c> rewriteengine on rewriterule .* - [e=http_authorization:%{http:authorization}] rewriterule ^([a-z]{2,3})(.*)$ http://vendauat.lauraashley.com/$1/made$2 [r=301,l] rewritecond %{request_uri}::$1 ^(/.+)/(.*)::\2$ rewriterule ^(.*) - [e=base:%1] rewritecond %{env:redirect_status} ^$ rewriterule ^app\.php(/(.*)|$) %{env:base}/$2 [r=301,l] rewritecond %{request_filename} -f rewriterule .? - [l] rewriterule .? %{env:base}/app.php [l] </ifmodule>
this condition:
rewritecond %{request_uri} !^made [nc]
will met because regex pattern says: if request never starts made
, %{request_uri}
variable always starts with /
. maybe want instead:
rewritecond %{request_uri} !^/[^/]+/made/
Comments
Post a Comment