Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am an htaccess newbee

I am trying to redirect the old URLS for my site to the new URLS for my site.

The old site used variables in the URL but the new site uses SEO friendly URLs.

When I try to redirect the old URL, it is not w=redirecting and I get the 404 page instead.

I am unsure if the SEO rewrite is the cause of the other rewrite condition failing.

How can I write the RewriteRule so that it redirects the old URL?

Options +FollowSymlinks RewriteEngine On

RewriteCond %{HTTP_HOST} ^WEBADDRESS.co.uk    
RewriteRule (.*) http://www.WEBADDRESS.co.uk/$1 [R=301,L] RewriteRule ^(.+).html index.php?seo_title=$1 [nc]    
redirect 301 /WEBPAGE http://www.WEBADDRESS.co.uk/WEBPAGE.html

RewriteRule ^http://www.WEBADDRESS.co.uk/test/test.php?c=viewtest&id=56&sat=9&mainsat=1&start=0$ http://www.WEBADDRESS.co.uk/NEW_URL.html

ErrorDocument 404 /PAGE_NOT_FOUND.html
share|improve this question
Great resource for this addedbytes.com/for-beginners/url-rewriting-for-beginners – hookedonwinter Oct 11 '10 at 17:20
up vote 1 down vote accepted

The problem I found was that the URL is split between the file and the variables as would be expected.

So everything after the ? is taken as a querystring.

You need to add a condition to check the query string (you can include Regular Expressions)

RewriteCond %{QUERY_STRING} ^viewtest&id=56&sat=9&mainsat=1&start=0$  
RewriteRule ^/test/test.php$ http://www.WEBADDRESS.co.uk/WEBPAGE.html? [R=301,L]

Also notice the ? after the redirected URL, this stops the variables being appended to the new URL

share|improve this answer

You can use javascript redirect on particular pages, If possible in your case.

share|improve this answer
That's not a good idea. If you want a redirect page instead of a transparent redirect, it's best to use the META REFRESH tag. That doesn't rely on JS (which web crawlers don't follow). But it's still best to use 301 if you want to transfer PageRank. – Lèse majesté Oct 12 '10 at 2:57
not possible the pages were dynamically generated from an older system that is no longer in use – Craig Angus Oct 13 '10 at 14:44
@Craig: i hope you already had tried HTML redirect, JS redirect and .htaccess redirect. right? – Amit Gupta Oct 14 '10 at 2:46

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.