Forum Moderators: phranque

Message Too Old, No Replies

Dynamic Variables 301 Redirect Problem

         

seofeed

8:03 am on Jul 29, 2006 (gmt 0)

10+ Year Member



I have a client to do 301 redirects for him. I set up the redirects to work with his old PHP code, but when his developer redid his site the code no longer worked.

Here is the code I had before:

Dynamic Url: www.example.com/products_form.php?action=24

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /products_form\.php\?action=(24)\ HTTP/
RewriteRule ^products_form\.php$ http://www.example.com/oily-skin-products/skin-cream/? [R=301,L]

Now basic 301 redirect code like below will not work:
Redirect 301 /example.php http://www.example.com/example/

I think the reason this is occurring is because the developer is using variables to call all of the links.

For example:
<?php echo $DiscoverLink[0];?>
<?php echo $ProductLink[0];?>

I'm pretty sure this is what is causing the problem.

Any ideas?

Thanks for the help.

Brandon

jdMorgan

4:28 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now basic 301 redirect code like below will not work:
Redirect 301 /example.php http://www.example.com/example/

That sounds like a fundamental server configuration problem. Without knowing what the other guy did (or could have done) to the server, it's pretty hard to even guess, here.

However, the 'basic' redirect above may have a problem: If example.php is defined as the DirectoryIndex file for the directory /example/, and if that rule is installed in an .htaccess file in the /example/ subdirectory, then that rule will create an infinite loop. In order to prevent looping, you'll have to use mod_rewrite and check THE_REQUEST if you want to 'change' requests for "/xyz/example.php" into requests for "/xyz/"

Jim