Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to redirect URLs and can't get anything to work. Here is what I'm hoping to do:

Old URL:

www.example.com/asp.pl?_puri=astore.amazon.com%2Fthegi02-20%2Fdetail%2FB0001L0DFA%2Fassid

Needs to redirect to:

www.example.com

Anyone know of any way to do that? If you can figure it out I can send over a $25 PayPal payment. I need it quick.

share|improve this question
    
Welcome to Serverfault, Steve. You'll need to tell us more, I'm afraid. What programming language is your site in -- .pl could mean Perl, is that true? You have access to the asp.pl script, I presume? Or if you don't have access to the script, do you have access to the server? Which webserver is it, Apache or Microsoft IIS, which version? –  Jesper Mortensen Sep 24 '09 at 16:57
    
What are you working with? Apache? IIS? –  RainyRat Sep 24 '09 at 16:58

2 Answers 2

Try this:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^_puri=astore.amazon.com%2Fthegi02-20%2Fdetail%2FB0001L0DFA%2Fassid$
RewriteRule ^asp\.pl$ http://www.example.com/ [L,R=301]

And if you also want to check the host name, add RewriteCond %{HTTP_HOST} =www.example.com to the rule.

share|improve this answer

You don't mention anything about your environment. From the .pl file extension I assume that you are using Perl, but I have no idea which webserver you are using.

If the file asp.pl does not exist, you can create a custom 404 error page to do the redirect. If you are using IIS, this can be accomplished using the IIS management tools.

If the file asp.pl exists, the redirect will have to happen as part of the Perl script in asp.pl, or via some URL rewrite scheme that understands what is and is not valid. If you are using Apache this can be accomplished using .htaccess files. In IIS you may have to insert an ISAPI rewrite module into the server processing stack. For information on doing a redirect in Perl, check this post on perlmonks.

You didn't mention if there were certain query strings that were valid and some that were invalid and should be redirected.

A little more information is required to fully answer your question.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.