Go Back   SEO Help | Search Engine Optimzation and Marketing Forums » Search Engine Optimization » SEO

SEO Anything SEO - troubleshooting, hints and tips, general ranking strategy - things to help boost search engine rankings

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 04-09-2008, 10:05 PM
New Member
 
Join Date: Apr 2008
Posts: 5
ericTM is on a distinguished road
Default 301/url help

Here's my situation, i think it's a unique one as far as these forums go, as i did a search and came up with nothing.

I have a website, www.jailbeta.com (i had to register it once i saw it was available...).

Anyway, my OLD way of urls (using mod_rewrite), was site.com/article/article-text-p-(article_id_from_database).html

however, recently i realized my URLs were quite long, so i decided i would strip out stopwords from it. Wrote the function, updated all my pages, all is great.

However, now i have site.com/article/some-article-with-stopword-p-123.html
and
site.com/article/some-article-with-p-123.html
if that makes sense.

so here's what i did:
in my htaccess:

Code:
RewriteRule ^article/(.*)-p-(.*)\.html$ old-articles.php?id=$2 [L,QSA]
### changed rewrite rule with stopwords, 301 the urls that had the stopwords to the url that doesnt. ###
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^old-articles\.php$ /redirect.php$1 [R=301,L]
RewriteRule ^article/(.*)-a-(.*)\.html$ articles.php?id=$2 [L,QSA]
redirect.php has some code to get the url from the database, strip out stopwords as normal, and forward it on to site.com/article/no-stopwords-here-a-123.html

here is redirect.php:
Code:
if(isset($_GET['id'])) {
	$redirID = intval($_GET['id']);
	$res = run_query("SELECT articles_sanitized FROM articles WHERE articles_id = '$redirID'");
	$newtitle = mysql_fetch_assoc($res);
	$newurl = '/article/'.makeLink($newtitle['articles_sanitized'], $redirID);
}

if($redirID != '' && $newurl != '') {
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: $newurl");
	exit();
} else {
	die('what exactly are you trying to do here?');
}
So basically i guess what i'm asking...is this the best way to do it? Since my mod rewrite paid no attention to anything other than the id (whatever was after -p-), i couldn't do any other kind of rewrite or redirect without getting myself into an infinite loop.

I'm no seo expert, i know very little actually, just a somewhere in between beginner and advanced php developer. any help is greatly appreciated, both from SEOers and PHPers/Apache geniuses.

also, how long should i leave this 301 in tact? can i leave it forever? since now all urls will be going to /article/something-a-123.html, as opposed to previously they were going to /article/something-p-123.html, will it make any difference once the engines update everything?

Thanks
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 03:48 AM
SEO Expert
 
Join Date: Mar 2008
Posts: 108
Delivos is on a distinguished road
Default

I'll answer the easy question first!

Leave the 301 there for as long as you can - as soon as it goes, you'll stop receiving love from outdated incoming links.

That is a pretty good way of doing things. You could've got into trouble quite easily but I think you've avoided a few potholes. Getting the stopwords out is definitely a good idea.

Going forward, you might was to be careful about changing the text part of the URL - like you say, the content only really depends on the id parameter, so:

Quote:
site.com/yes-yes-p-12.html
has the same content as:

Quote:
site.com/no-no-p-12.html
and that could lead to duplicate content issues. Watch out for it!

One thing you might like to optimise is that you can in fact remove the -a- from your URLs, seeing as the number is always the last thing before the .html and is preceded by a hyphen, thus making it easy to identify without the -a-. Also, you don't really need the first part of the URL that you're capturing in brackets. An example RewriteRule might look like:

RewriteRule ^article/.+?-([0-9]+)\.html$ articles.php?id=$1 [L,QSA]

If you want any part of that explained, post and we'll be happy to help!
__________________
SEO Rant
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 07:22 AM
New Member
 
Join Date: Apr 2008
Posts: 5
ericTM is on a distinguished road
Default

thanks for the great reply!
i've taken out the -a- from my urls using the example rewrite rule you gave and it works great.

so now my old /article/something-with-stopwords-p-123.html is being 301d to /articles/something-with-123.html.

The whole point of what i was trying to do with the 301s is to stop duplicate content. had i kept /stopword-url-p-123.html not 301 to /no-stopword-url-123.html, that would have created duplicated content, right?

I have about 220something pages indexed on google when i do a site:, about 150 of which have the stopwords and -p-123.html url, so now i will begin to see these urls drop out of the index and be replaced with the /no-stopword-123.html urls, right?

Sorry for all the redundant and probably amateur questions somehow my site ranks very well for a lot of good keywords, even though my domain is only a few months old and so far i have no backlinks, so i want to do whatever i can to at least keep it that way, if not make it better.

thanks again!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 07:38 AM
SEO Expert
 
Join Date: Mar 2008
Posts: 108
Delivos is on a distinguished road
Default

Quote:
The whole point of what i was trying to do with the 301s is to stop duplicate content. had i kept /stopword-url-p-123.html not 301 to /no-stopword-url-123.html, that would have created duplicated content, right?
Yeah, that sounds about right.

Quote:
I have about 220something pages indexed on google when i do a site:, about 150 of which have the stopwords and -p-123.html url, so now i will begin to see these urls drop out of the index and be replaced with the /no-stopword-123.html urls, right?
This should happen too! Give it a month or so, or at least a week after Googlebot has crawled each redirect and new page.

Good luck!
__________________
SEO Rant
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 09:52 AM
New Member
 
Join Date: Apr 2008
Posts: 5
ericTM is on a distinguished road
Default

awesome!
thanks again for the help
Reply With Quote
  #6 (permalink)  
Old 04-11-2008, 09:35 AM
Junior Member
 
Join Date: Mar 2008
Location: UK
Posts: 85
DaveJ|UK is on a distinguished road
Default

Quote:
Originally Posted by ericTM View Post
...somewhere in between beginner and advanced php developer.
Intermediate

I've only scanned over this discussion but I don't think it was mentioned; I'd recommend checking each request to make sure the URL is in the format it should be, redirecting to the proper one if it's not.

Although unlikely, it would be possible for someone to link to /the-wrong-url-101.aspx when it should be /this-article-101.aspx
Reply With Quote
  #7 (permalink)  
Old 04-11-2008, 08:06 PM
New Member
 
Join Date: Apr 2008
Posts: 5
ericTM is on a distinguished road
Default

Quote:
Originally Posted by DaveJ|UK View Post
Intermediate
fair enough

As for the links, once it hit's redirect.php, it will 301 to the correct /text-before-id-123.html, regardless of what the url of the originating link was. Along with that, all of the internal links on my site are controlled by a function that returns the actual text of the link, so no chance of confusion internally.

Thanks for all the great replies guys
Reply With Quote
  #8 (permalink)  
Old 04-12-2008, 08:18 AM
Junior Member
 
Join Date: Mar 2008
Location: UK
Posts: 85
DaveJ|UK is on a distinguished road
Default

I think you misunderstood what I meant. Perhaps I can explain better.

I'm not talking about the redirect to the new url format.

I know you have a function to generate the url's.

Before you display the content, you should check that the url requested is the same as the one you expected.

If the request is for:

/the-wrong-url-101.aspx

But your function tells you it should be:

/the-correct-url-101.aspx

then you should redirect to the correct one. If not, then display the page as normal.
Reply With Quote
  #9 (permalink)  
Old 04-12-2008, 10:09 AM
New Member
 
Join Date: Apr 2008
Posts: 5
ericTM is on a distinguished road
Default

Ahh. I understood what you were saying, but i was confusing myself. When it gets to redirect.php, it grabs the correct url from the database and 301's to it. But what i wasnt thinking of was that it wont get to redirect.php if the url is in the correct format in the first place (correct format is without the -p-123.html). So i wrote some script in the article page to check between the requested url and the correct url from the database, and 301 to the correct url if they don't match

I don't think it will ever be an issue, as you said, but its good to have just in case somebody messes up in linking to one of the articles...

Great help guys, thanks again and again!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Have your Site manually submitted to 1028+ SEO Friendly Web Directories
All times are GMT -5. The time now is 12:23 PM. Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.