Forum Moderators: phranque

Message Too Old, No Replies

mod proxy & mod rewrite interfering?

         

dfresh4130

9:48 pm on Nov 3, 2014 (gmt 0)

10+ Year Member



I'm working on some SEO optimization for our site and running into some confusing behavior. I think the the rewrite and proxypass configs are conflicting. Currently we have the below proxypass config:


ProxyPass /order/app1/ http://1.2.3.4/app1/
ProxyPassReverse /order/app1/ http://1.2.3.4/app1/


We're trying to implement some SEO rewrites for the URLs like below:

http://www.example.com/order/app1/category1/Abc123-3R19D3-abc-Product/123456
http://www.example.com/order/app1/category1/Abc-IgF-E-L-Item1-Item2-Item3-Item4-Product/12345
http://www.example.com/order/app1/category1/Abc-IgF-E-L-Item1-Item2-Product/AB1-12345

They'd like them rewritten to where /order/app1/category1 isn't required so just the last two sections are valid when they hit apache. I came up with the below rewrite rule and after testing realized I need to add the P flag since the content isn't hosted locally.


RewriteRule ^/(.*)-Product/(.*)$ /order/app1/category1/$1-Product/$2 [P,NC,L]


After I add that rule I get a 400 error. It seems like my proxypass and rewrite configs are stepping on each other. Do I need to modify my proxypass config to be more specific in order implement rules like this or am I going down the wrong path?

lucy24

11:58 pm on Nov 3, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Did you mean literally 400 (Bad Request), or did you mean some other 400-class error? Do error logs provide further information?

As written, it seems like the rule would create an infinite loop. The .* part could mean absolutely anything-- including a repetition of the material in the target.

I assume this rule is lying loose in the config file, hence the leading slash. Change the pattern to say something like

^/([^/]+)-Product/(.*)


so there can be no superfluous directories in the URL. Note incidentally that the closing anchor here isn't needed, though it will do no harm.

This may or may not fix the 400 error, but let's start from a position of doing everything right so the server has no excuse ;)

Oh and: never say [NC] in a rule that creates an internal rewrite, unless you particularly want octuplicate content. The only exception is if you're detouring to a php-or-equivalent script that will perform its own casing tests and issue a 404 or 301 as appropriate.