Parmanent Redirect 301 Problem

New to mod_rewrite? This is a good place to start.

Parmanent Redirect 301 Problem

Postby mehboob » Thu Oct 22, 2009 7:49 pm

Hey Guys,
I am kind of new and there is the situation I am facing..

I used redirect rule to go from www.domain.com/index.php?act=register to www.domain.com/register

Code: Select all
RewriteRule ^register$ index.php?act=register [L]


Now the problem is that google.com and other search engines already crawled www.domain.com/index.php?act=register so they are not crawling the new URL. www.domain.com/register

How should I setup R=301 in this situation?

I trield
Code: Select all
RewriteRule ^index.php?act=register$ register[R=301]


But no luck in that. Maybe because I am redirecting to a URL that is previously redirected using rewriterule.

Can someone help me out?
mehboob
 
Posts: 4
Joined: Wed Oct 14, 2009 6:39 pm

Postby richardk » Fri Oct 23, 2009 9:10 am

Query strings are matched with RewriteConds and the %{QUERY_STRING} variable.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?act=register(&.*)?$ [NC]
RewriteRule ^index\.php$ /register? [R=301,L]

RewriteRule ^register$ /index.php?act=register [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 24 guests

cron