Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
1  
Great resource for this addedbytes.com/for-beginners/url-rewriting-for-beginners –  hookedonwinter Oct 11 '10 at 17:20

2 Answers 2

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
1  
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? –  articlestack Oct 14 '10 at 2:46

Your Answer

 
discard

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.