views:

27

answers:

1

I am having problems doing a redirect for some URLS, the ones from the old site that have a ? sign, won't redirect, every other URL will do. example: OLD: /laser-alignment-resources/presentations.cfm?pres=diaphragm

NEW: http://www.acquip.com/en/presentations/47-presentation-internal-laser-diaphragm-alignment

Won't work, I am sure I did something wrong but I am a n00b when it comes to .htaccess

all the URLs are in the same format, 14 in total:

OLD:/laser-alignment-resources/presentations.cfm?pres=gas New:http://www.acquip.com/en/presentations/48-presentation-gas-turbine-thermal-alignment

OLD: /laser-alignment-resources/presentations.cfm?pres=train NEW:http://www.acquip.com/en/presentations/49-presentation-complete-machine-train-alignment

any help will be appreciated.

A: 

Your question isn't clear on how you're trying to perform the redirects in your .htaccess file, so for next time I'd recommend that you post some samples of the code that you've tried so that we can help you more easily.

Based on your Apache tag and the problem you're describing, I'm going to assume that you were using mod_alias though, trying to do something like this:

Redirect 301 /laser-alignment-resources/presentations.cfm?pres=diaphragm http://www.acquip.com/en/presentations/47-presentation-internal-laser-diaphragm-alignment

This doesn't work though, as the Redirect directive seems to only examine the path portion of the request, and not the query string.

If you have mod_rewrite available, you can setup rewrite rules for the URLs that you need to redirect based on their query strings. This would look something like this:

RewriteEngine On

RewriteCond %{QUERY_STRING} =pres=diaphragm
RewriteRule ^laser-alignment-resources/presentations\.cfm$ http://www.acquip.com/en/presentations/47-presentation-internal-laser-diaphragm-alignment [R=301,L]

RewriteCond %{QUERY_STRING} =pres=gas
RewriteRule ^laser-alignment-resources/presentations\.cfm$ http://www.acquip.com/en/presentations/48-presentation-gas-turbine-thermal-alignment [R=301,L]

...and so on. You can keep your currently working Redirect statements, as they should work fine side-by-side with these rules.

Tim Stone
Sorry If I wasn't clear, but you actually figured it out pretty well, I was using 301 redirect not mod_rewrite.I just tried with mod_rewrite and it isn't working either.I called the hosting company and they said they have mod_rewrite enabled on their servers.What else can it be?
Terumo
No problem, I just wanted to make sure I was providing an answer that would be useful for you. As far as it not working goes, I'm not sure why it shouldn't be, but I'll investigate after work today to see if I can come up with an alternate solution.
Tim Stone
@Terumo - Hmm, it works alright on my test server. When you access the URLs with the query strings attached to them, nothing at all happens? You can test that `mod_rewrite` is working in general with a rule like `RewriteRule ^rewrite-test$ http://stackoverflow.com/ [R=301,L]` and going to that `rewrite-test` URL and seeing if you're redirected to Stack Overflow.
Tim Stone