Jump to content

Help with fixing my SEO problems on a PHP site.


Cam4

Recommended Posts

SEO moz is telling me that I have a few issues on my site. The biggest one being duplicate content. They give me the URL to each page that has this problem. The solutions I have found have told me to place a 301 redirect or a canonical tag to these pages. However, seeing as my site is php and has dynamic pages, this solution will not work. Unless I am not understanding where these tags can go. If I try to go to a specific category page on my site I will be brought to one category page because each page is built from the server depending on the way you get to it.

 

I have contacted SEO moz many times and they have told me that they are not web experts and can not solve this issue. In fact, the person helping me in the forum from SEO moz is a history major! They only tell me the problems that their site finds when I do a web crawl. Very frustrating! So now I am trying to find any php help I can get with this issue.

 

Does anyone have a solution?

 

 

Link to comment
Share on other sites

PHP or static HTML does not make a difference. Either of those solutions will work and which you choose depends on the circumstance.

 

Some degree of overlap is alright, but the problem is when you have more than one page which behave the same way or serve the same purpose. For example, with a forum like phpfreaks the friendly URL could be

/topic/292324-help-with-fixing-my-seo-problems-on-a-php-site/
but the backend URL (without rewriting) might be

/viewtopic.php?id=292324
Naturally both of those have to work on your site, but if you don't do anything beyond the rewriting then both of those URLs will generate the same page. That's duplicate content. With that example you should 301 redirect because you want people to use the friendly URL and not the backend URL.

 

I can't come up with an example for canonical URLs but you would use those in cases where you want one thing to appear in two different places. The canonical URL indicates the "authoritative" or "primary" URL for the page so indexers will know that it's not so much duplicate content but rather content that is available in a second place (and it will focus on the first one).

 

What kind of pages are being marked as duplicates? Of what other pages?

Link to comment
Share on other sites

Here are two urls that I was given on SEOmoz. I only gave you two but SEO is telling me that there are 50 duplicates!

 

So this one is a login page:

 

http://www.maxamps.com/cart.php?mode=login

 

http://www.maxamps.com/cart.php?mode=login&refurl=%2Fproducts.php%3Fcat%3DLiPo%2B8000mah%2BPacks

 

 

 

These examples are of one of our category pages, which has 27 duplicates according to SEO moz:

 

http://www.maxamps.com/categories.php?cat=Traxxas

 

http://www.maxamps.com/categories.php?cat=OFNA

 

I see that I can add these redirects, but my issue is where to put them. Some of the pages that are duplicates are just other category pages, but they are not the same page. Also, if my category page is having duplicates well, I only have one actual product page in my code because it generates the rest when some on searches for something or gets there a certain way. So how am I to add a redirect or a conanical to certain category pages to make them priorty or redirected? My category page is basically just variables that pull each category in...

 

I hope I am explaining this the right way.

Link to comment
Share on other sites

Oh. Well they're being stupid and not taking into account the query string. Those two pairs, at least, aren't duplicates.

 

[edit] Well, technically the cart.php one is kinda duplicate because the relurl parameter does not affect the displayed page. You should noindex it. But that's a very minor concern.

Edited by requinix
Link to comment
Share on other sites

Thank you for your help so far.

 

So basically each duplicate has a different reason for being that way and they will each take a different way to solve?

 

But it still does not answer my main question. Which is where do I even put this coding? Or make these changes if I only have one page to work from on fifty duplicates. Does this make sense? Am I asking the wrong question to retrieve my answer?

Link to comment
Share on other sites

Each will have a reason but many of them could be the same "problem" as those two: different query strings. You would have to look at each to decide whether the tool is wrong.

 

Three basic outcomes for each:

1. The tool is wrong: the difference(s) in the query string affect what the page shows so there is no duplicate content

2. The tool is right: the difference(s) in the query string do not affect the page, one or both of the pages should be marked noindex because the content is irrelevant for SEO

3. The tool is right: the difference(s) in the query string do not affect the page, one of the pages should redirect to the other (if you want one URL to be "correct") or they both should indicate the canonical URL (if you don't want to redirect)

 

categories.php falls under outcome 1, cart.php falls under outcome 2 or 3 (I'd go for 2 because the shopping cart page is meaningless in SEO).

 

So the code.

 

Canonical stuff looks like

<link rel="canonical" href="http://www.example.com/path/to/canonical/page.php">
<link rel="canonical" href="http://forums.phpfreaks.com/topic/292324-help-with-fixing-my-seo-problems-on-a-php-site/">
Goes in the .

You should really put that on all your pages, not just ones that look like duplicates.

 

Redirect stuff... is a bit trickier, if you deal with query strings. You can't just compare URLs (the actual vs the one you want) because the order of key/value pairs in the query string doesn't matter, and "a=1&b=2" should be treated the same as "b=2&a=1". There are also sometimes query string keys you want to ignore, like relurl.

Without any testing done, the code looks like this:

$correct_path = "/path/to/this/page.php";
$correct_qs = array("query string keys" => "query string values");

$actual_path = substr($_SERVER["REQUEST_URI"], 0, strcspn($_SERVER["REQUEST_URI"], "?")); // path up to the ?
$actual_qs = $_GET;
$ignore_qs = array_flip(array("relurl", "other keys to ignore"));

// get a list of the actual values excluding the ignored values
$diff_qs = array_diff_key($actual_qs, $ignore_qs);
// get a list of just the ignored values
$extra_qs = array_intersect_key($actual_qs, $ignore_qs);

// if the path or query strings don't match
if ($correct_path != $actual_path || $correct_qs != $diff_qs) {
	$target_qs = array_merge($correct_qs, $extra_qs); // the correct values plus the ignored values
	header("Location: " . $correct_path . ($target_qs ? "?" . http_build_query($target_qs) : ""));
	exit;
}
That kind of code should go into a function somewhere, naturally.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.