Question

I recently moved from a asp.net host to a PHP host. I am trying to setup 301 redirects of my old urls using .htaccess. Here is what I want to accomplish:

old url: http://www.vasanth.in/downloads/download.aspx?file=file.zip
new url: http://www.vasanth.in/downloads/download.php?f=file.zip

I tried the following:

RedirectMatch 301 /downloads/download.aspx\?file=(.*)$ http://www.vasanth.in/downloads/download.php\?f=$1

This does not seem to work? What am I doing wrong?

Was it helpful?

Solution

Use mod_rewrite, something like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^file=(.+)$
RewriteRule ^(.+)\.aspx$ $1.php?f=%1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top