Forum Moderators: phranque

Message Too Old, No Replies

301s alongside mod rewrite causing problems

.htaccess guru needed

         

fishfinger

2:40 pm on Jan 12, 2007 (gmt 0)

10+ Year Member



I am trying to sort out a php site that is a mess and I am having real difficulties with the htaccess. I thought that the 'legacy' rules that are in existence already were causing problems, but the more I look into this the more confused I become.

The existing rule :

RewriteRule ^detail-(.*)/(.*)\.htm product-detail\.php?prod_id=$1&prod_title=$2

is to deal with the shopping cart. There are other php pages in the site that are static urls (e.g. terms.php)

The htaccess was not implemented from rollout so Google has already indexed a load of these product urls :

product-detail.php?prod_id=1 

alongside the re-written ones.

I am therefore trying to write different 301s individually in htaccess to clear up the duplicate content - but they don't work.

Fr'instance I've tried re-writing

product-detail.php?prod_id=1 

(which is the real server side page) to
/detail-1/prodtitle.htm

(which is what the navigation uses now) but it doesn't work.

Is the current htaccess rule causing the problem?

It gets worse.

I've tested and I can write a general 301 from terms.php to another page but even here something wierd is happening. The url is not changing - instead the content from the other page that I want to redirect to is being fetched and displayed under the url requested.

This has me worried that there is some server configuration error.

Can anyone with some experience shed some light?

jdMorgan

3:27 pm on Jan 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't simply rewrite from static to dynamic, and then redirect back from dynamic back to static -- That will put your server into an "infinite" loop.

This thread [webmasterworld.com] in the Apache forum library may be quite helpful to you if read carefully.

Jim

fishfinger

10:52 am on Jan 13, 2007 (gmt 0)

10+ Year Member



Thanks, I'll give it a go.

As far as the second problem I'm having goes (where the 301 redirect is essentially 'hi-jacking' the page it's supposed to send the browser to) do you know what coudl be causing this?