Forum Moderators: phranque
[edited by: jdMorgan at 1:27 pm (utc) on Sep. 24, 2009]
[edit reason] example.com [/edit]
The description "not working" for code we can't even see is of no help here.
Be aware that RewriteRule cannot see parameters attached to a URL.
You need a preceding RewriteCond to detect those.
There's very many prior examples here, at least several each week, to pick for starters.
Redirect 301 /asp.pl?_puri=astore.amazon.com%2Fthegi02-20%2Fdetail%2FB0001L0DFA%2Fassid [mainpage.com...]
and it works with regular html files, but not with those URLs. Any idea why?
Use mod_rewrite instead of mod_alias, and use a RewriteCond examining %{QUERY_STRING} to match and capture parts of the query string for re-use in the new URL.
The resources cited in our Forum Charter may prove useful to you.
Jim
[edited by: jdMorgan at 3:25 pm (utc) on Sep. 24, 2009]
From above:
The resources cited in our Forum Charter may prove useful to you.
We also have a site search facility to turn up hundreds of previous examples, and there are several related threads in our Forum Library (Please see links at the top of this page).
To dull any perceived 'edge' to this response, I'd like to state that "handing you what we think is the solution to your problem" and saying, "Here, just use this" is doing you no favors; The code could be a perfectly-correct solution to the wrong problem.
This expedient would also leave you with no understanding of the solution, and no redress should a problem arise other than to post again in this (or another) forum and hope that your luck is better the second time. We'd prefer to "teach you to fish" instead of "handing you a fish," as it were.
While server configuration code tends to be compact, it is also obscure and very powerful; Very small changes can have very large (and often detrimental) effects on the operation (and success) of your site. One single typo can immediately take down your server (if you're very lucky), or it can sit there causing subtle problems, quietly destroying your search engine rankings over time. As with a chainsaw, it is best to understand how it operates before trying to use it.
Jim
RewriteCond %{QUERY_STRING} ^_puri=astore.amazon.com[b]\%2F[/b]thegi02-20[b]\%2F[/b]detail[b]\%2F[/b]B0001L0DFA[b]\%2F[/b]assid$
RewriteRule [b]^asp\.p[/b]l$ http://www.example.co[b]m/?[/b] [R=301,L]
It is also possible that the %2F sequences in the query string will be un-escaped before they are tested, in which case. you'd want:
RewriteCond %{QUERY_STRING} ^_puri=astore.amazon.co[b]m/t[/b]hegi02-2[b]0/d[/b]etai[b]l/B[/b]0001L0DF[b]A/a[/b]ssid$