Featured post
apache - Redirect URL using Query String parameter in URL -
i have bunch of urls old site updated ee2. these urls this:
http://www.example.com/old/path.asp?dir=folder_name
these urls need redirect to:
http://www.example.com/new_path/folders/folder_name
not folder_name
strings match folder_name
url segments, these need static redirects.
i tried following rule particular folder called "example_one" maps page on new site called "example1":
redirect 301 /old/path.asp?dir=example_one http://www.example.com/new_path/folders/example1
but doesn't work. instead of redirecting 404 error telling me http://www.example.com/old/path.asp?dir=example_one cannot found.
edit:
there's secondary problem here may or may not related: have catch-all rule looks this:
redirect 301 /old/path.asp http://www.example.com/new_path
using rule, requests first 1 above redirected to:
http://www.example.com/new_path?dir=folder_namewhich triggers 404 error.
just had scour google bit more find proper syntax mod_rewrite.
using example above:
rewritecond %{query_string} ^dir=example_one$ rewriterule ^/old/path\.asp$ /new_path/folders/example1? [r=301,l]
this fixes both of problems above -- why ee 404ing 1 parameter in query string, problem still unsolved, works workaround problem.
you can redirect urls specific page parameter may have different value each time. 1 example of google utm campaign tracking (in situations tracking query string triggers 404):
link: http://www.example.com/?utm_source=xxx&..... (triggers 404)
should redirect to: http://www.example.com
rewritecond %{query_string} ^utm_source= rewriterule ^$ http://www.example.com? [r=301,l]
note: redirect requests homepage, defined ^$. if want redirect utm requests different page, you'll need change first part of rewriterule.
- Get link
- X
- Other Apps
Comments
Post a Comment