| SEO Anything SEO - troubleshooting, hints and tips, general ranking strategy - things to help boost search engine rankings |
![]() |
|
|
Thread Tools | Display Modes |
|
|||
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]
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?');
}
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 ![]() |
|
||||
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:
Quote:
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 |
|
|||
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! |
|
||||
Quote:
Quote:
Good luck!
__________________
SEO Rant |
|
|||
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 |
|
|||
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 ![]() |
|
|||
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. |
|
|||
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! |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
All times are GMT -5. The time now is 07:02 PM.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.








Linear Mode
