Forum Moderators: phranque

Message Too Old, No Replies

Lost SEO juice due to mod rewrite

         

kingdavid

11:46 pm on Sep 4, 2008 (gmt 0)

10+ Year Member



I used a mod rewrite of the urls to put the parameters inside the uri and now I've lost all of our SEO juice and was wondering if we can do a 301 redirect to make up for it, I tried doing RewriteRule ^contact\.php$ index.php?tpl=contact [R=301,L] but it just kept looping. Is there any way to mask urls to make them search engine firnedly and also apply 301 redirects to them to pass along any applicable SEO rankings?

jdMorgan

1:01 am on Sep 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It would be very helpful if you detailed exactly what you did, with what URL-set, old-to-new URL-mapping, and with what code, since a properly-coded dynamic-to-static URL change-over would not have caused loss of link juice. Rather than apply a band-aid, it would be better to surgically repair the underlying problem.

If you'd like some background on a correct implementation, see the thread Changing Dynamic URLs to Static URLs [webmasterworld.com], in our Forum Library.

Jim

kingdavid

5:15 pm on Sep 5, 2008 (gmt 0)

10+ Year Member



hi jdMorgan,

Thank you for you response. The old URL's were: www.example.com/show.php?mi=184 and we used a mod_rewrite to change the new urls to something like: http://www.example.com/shows/musicals/184/some-broadway-play-tickets.php
By using the following rewrite rule:
RewriteRule ^shows/(.*)/(.*)/(.*)\.php$ show.php?cname=$1&mi=$2&mname=$3 [L]

We would really like to have the old URL's 301 to the new ones but like I said it keeps looping, is there anyway around this?

[edited by: jdMorgan at 7:42 pm (utc) on Sep. 5, 2008]
[edit reason] Use example.com please. [/edit]

jdMorgan

7:41 pm on Sep 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your original rule did not "change the URLs", it simply mapped the new "SE-friendly" URLs to your script, and filled in the query strings parameters from the "virtual subdirectories" in the friendly URL.

You changed the links on your pages to point to the new URLs, and then added mod_rewrite code to "connect" those URLs back to your script.

It is important to understand this, to avoid confusing the discussion.

Your original rule is very inefficient. You might want to use more-specific regex subpatterns like this to speed it up:

RewriteRule ^shows/([^/]+)/([^/]+)/([^.]+)\.php$ show.php?cname=$1&mi=$2&mname=$3 [L]

So, you've already done steps one and two described in the thread I linked to above, and now you want to do step three. After reading that thread, do you have a specific question about your code?

Jim

kingdavid

8:07 pm on Sep 5, 2008 (gmt 0)

10+ Year Member



Ok, so just to clarify, re-mapping URL's would not wipe out a particular URL's SE reputation? Does that mean that Google (or whichever SE) actually gets the redirect address, and knows it's the same URL as it used to be?

jdMorgan

8:44 pm on Sep 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, it's a new URL for the same old "resource."

It used to be that show.php?cname=do&mi=re&mname=mi was the URL and the filename.

Now the URL is example.com/shows/do/re/mi.php and the filename is show.php?cname=do&mi=re&mname=mi, and your mod_rewrite rule takes care of the new URL-to-filename mapping.

It will take Google some time --guessing up to three months-- to figure out that you've changed the URLs and to pass the PR from the old URL to the new. However, you do need that third step to help it along, as described in the cited thread -- A 301 redirect from show.php?cname=do&mi=re&mname=mi to example.com/shows/do/re/mi.php for direct client requests only.

The code is in that thread.

Jim

kingdavid

9:06 pm on Sep 5, 2008 (gmt 0)

10+ Year Member



I did this: RewriteRule ^shows/Musicals/184/keyword-keyword-keyword.php$ http://www.example.com/show.php?mi=184 [R=301,L] and it caused an infinite loop. I'm not sure what you mean by direct client requests only. Am I still doing something wrong?

jdMorgan

9:15 pm on Sep 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, so did you read that thread at all? It describes this situation exactly, and the reason that you must redirect from show.php?cname=do&mi=re&mname=mi to example.com/shows/do/re/mi.php for direct client requests only. It also gives the code modification that is required to accomplish just that.

Please click on the link I provided above and read the cited thread looking for the "third step," so that I do not have to repeat myself -- and possibly make a small error that will cost you more time.

We make much use of archival threads here, and for good reason... For one thing the code has been tried by many people and found to work properly, and for another, it saves needless repetition.

Take the rule shown there, modify it, and post back here if any specific propblems or questions.

Thanks,
Jim

kingdavid

6:57 pm on Sep 7, 2008 (gmt 0)

10+ Year Member



Oh, sweet, sorry about that. I missed something in the thread you sent me. Now I got it.

Thanks, you saved me bigtime!

jdMorgan

7:22 pm on Sep 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, it's important to understand the whole process so that you can come up with the right "custom implementation" for your site and be comfortable maintaining it, modifying it, etc. in the future. And if there's a problem, you'll know what the code is intended to do, and so won't have to "depend on the kindness of forums" (or your hosting company) to get it working properly or to make a change.

Glad that helped...
Jim