Mobile app version of vmapp.org
Login or Join
Gail5422790

: Duplicate content for sub domains i.e. example.com/subdomain/index.php seen the same as example.com/subdomain/ Possible Duplicate: What is duplicate content and how can I avoid being penalized

@Gail5422790

Posted in: #DuplicateContent #Htaccess #Subdomain

Possible Duplicate:
What is duplicate content and how can I avoid being penalized for it on my site?




I have a website with some sub domain folders and seomoz is picking them up as both duplicate content and duplicate page titles. In actual fact, its the same page i.e. example.com/subdomain/index.php is seen the same as example.com/subdomain/ I want to point everything to the later.

I'm sure this will be done in the htaccess file. I sorted it for the main site (home page) and everything works fine but when I tried copying the code and re jigging it for the subdomains, either nothing happened or the page went down.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cody1181609

This is a fairly common problem and John Conde's suggestion to use canonical URL's is a safe bet.

You may have other options, depending upon how comfortable you are with editing your server configuration and PHP scripts.

Apache mod_rewrite directive

Advantages: Does not require modifying your PHP application.

Disadvantages: Processing overhead for the rewrite engine on every request. (Note that the disk access overhead associated with enabling the AllowOverride directive for .htaccess support is typically greater than the modest processing overhead incurred by mod_rewrite)

The following mod_rewrite directives will permanently redirect users to the directory requested if index.php is appended:

RewriteEngine on
RewriteRule (.*)/index.php$ // [R=301,L]


PHP conditional

Advantages: Does not require use of mod_rewrite, processing overhead incurred only on PHP file requests.

Disadvantages: Requires editing PHP scripts and introduces potential for scripting errors. Requires knowledge of PHP troubleshooting should errors occur.

If your application consists of multiple files which all include the same heading file or template, you can add the following conditional block to the file before any HTML is printed or echoed: (calls to PHP's header() function will fail if any output has been sent to the user)

<?php
$uri = strtok($_SERVER['REQUEST_URI'],'?');
if ( 'index.php' == substr($uri, -9) )
{
$redirect_uri = ($_SERVER['HTTPS']) ? 'https://' : 'http://';
$redirect_uri .= $_SERVER['HTTP_HOST'];
$redirect_uri .= substr( $uri, 0, strlen($uri) - 9 );
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: ' . $redirect_uri );
}
unset($uri);

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme