Welcome to WebmasterWorld Guest from 54.145.209.107

Forum Moderators: Ocean10000 & incrediBILL & phranque

Rewrite not working

trying to redirect Dynamic URL

   
3:38 pm on Nov 6, 2009 (gmt 0)

5+ Year Member



Ok, so I thought I was beginning to understand these, but for some reason I cannot get this one to work...

Here is the original URL:


http://www.example.com/index.php/quality-boards/utca-a-cpci?view=product&product_id=3293&layout=picmg

I need to redirect it to:


http://www.example.com/index.php/quality-boards/utca-a-cpci/micro-tca

Here is my rewrite:


RewriteCond %(QUERY_STRING) ^view=product&product_id=3293&layout=picmg$
RewriteRule ^index.php/quality-boards/utca-a-cpci$ http://www.example.com/index.php/quality-boards/utca-a-cpci/micro-tca? [L,R=301]

I placed the ? on the end to see if I could force it to redirect WITH the query string appended (although i don't need it), but the statement just doesn't seem to be doing anything. I have other redirects like this that are working fine.

any ideas?

Thanks

4:53 pm on Nov 6, 2009 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Change ( and ) to { and } for starters...

Secondly do not re-append the query string otherwise you'll have an infinite redirect loop.

Why do you need /index.php/ as a part of the new URL? If you're moving to new URLs, I would omit that part in your new URL format.

Be aware that your redirect does not work if there are additional parameters and/or the parameters are in a different order. That could be exploited by a competitor to make your site show Duplicate Content.

5:08 pm on Nov 6, 2009 (gmt 0)

5+ Year Member



Thanks for your reply! I have a few questions:

Change ( and ) to { and } for starters...

>>Doh! Sorry. Brain not working on too little sleep...

Secondly do not re-append the query string otherwise you'll have an infinite redirect loop.
>>Got it. I wasn't planning on adding it, I was just trying to get it to do SOMETHING.. :) This is on a test server so I can try out my crazy .htaccess theories...

Why do you need /index.php/ as a part of the new URL? If you're moving to new URLs, I would omit that part in your new URL format.

>>I was looking at that. The site runs on Joomla, and I believe it is part of their SEF functions to add it. I have seen a few posts on this forum on removing it, and it looks like it might be a bit tricky? I would definitely like to remove it though...

Be aware that your redirect does not work if there are additional parameters and/or the parameters are in a different order. That could be exploited by a competitor to make your site show Duplicate Content.

>>So how would I make this work without creating that concern? This redirect is a 1-to-1, as google has the old URL cached and I am trying to clear up the 404 that is being generated. I realize those params can be in different orders, but I am not sure what you would do about it?

Thanks again for the help!

5:27 pm on Nov 6, 2009 (gmt 0)

5+ Year Member



BTW, I wanted to empasize that "Trying out my crazy .htaccess theories" actually means I am reading over the manual and posts on this site and gaining understanding. Since it is on a test server I may go out on a limb once in a while to try something, but I do try to have a good understanding of what I am doing and its implications. I am just still new to all of this.. :)
7:15 pm on Nov 6, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



If the parameters can be in any order, and some but not all could be missing and you need to redirect all of those variants with this rule, then you will need up to 15 RewriteConds, specifying the query string in all of the variations that you want to redirect. If *all* could be missing and you'd still want to redirect, then the query string is likely irrelevant, and you can remove the RewriteCond entirely.

However, if you are just trying to fix one incorrect URL in the Google SERPs, then what you have is fine unless you have apre-existing internal rewrite from the 'friendly' URL back to this same query-string URL that you are trying to redirect. If this is the case, then that pre-existing internal rewrite and this new redirect will countermand each other, leading to an infinite rewrite/redirect loop, and so you new rule here will need more work.

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month