Forum Moderators: phranque

Message Too Old, No Replies

R=302 to R=301 broke my pages

Does permanent redirects break a page if it is dynamic?

         

scarything

1:48 pm on Nov 11, 2006 (gmt 0)

10+ Year Member



I use .htaccess on my site to redirect urls to the database processing page for a search e.g.

www.website.com/links/category

becomes

www.website.com/links.php?keywords=category

using a rule like this:

RewriteRule ^(.*)(index¦links)/(([A-Za-z0-9-]+)/?)$ $1$2.php?keywords=$4 [L]

This has been working fine for many months. However after some reading I decided to make use of permanent redirects for the benefit of google Pr so my rule became this:

RewriteRule ^(.*)(index¦links)/(([A-Za-z0-9-]+)/?)$ $1$2.php?keywords=$4 [R=301,L]

I tested this and it worked fine. After a few hours I noticed my webserver stats were showing permanent redirects. Success I thought. However the next day the links did not work anymore. In IE users were being dumped back at the base domain and in FireFox the page was totally blank, not even an error message. I reverted back to plain [L] i.e. defaulting to R=302 and the site works fine again.

From my reading of this and other forums it seems like lots of people are using R=301 with no problems and I could find no examples of any posts of a problem like mine.

Any thoughts or ideas what went wrong?

jdMorgan

2:13 pm on Nov 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I use .htaccess on my site to redirect urls to the database processing page for a search e.g.

The problem is that you've confused external redirects with internal rewrites, and essentially have done something unnecessary -- as well as backwards -- to your site.

For a dynamically-generated site on which you wish to use static-looking URLs for the sake of spiderability or usability, you should rewrite the static-looking URLs that appear as links on your pages to the dynamic URL-paths that are needed to invoke your page-generation script. (This is what you had done previously.)

Then, if your site has been previously spidered using dynamic URLs, you might also want to redirect those old dynamic URLs, only when directly requested by the client, back to the corresponding static URL. You may in fact now need to do this second step in order to recover search-engine-ranking-wise from your current problem.

The whole process is outlined in the thread Changing Dynamic URLs to Static URLs [webmasterworld.com] -- A basic introduction to using mod_rewrite on Apache server to implement search-engine-friendly static URLs on dynamically-generated sites, in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim