Mobile app version of vmapp.org
Login or Join
Jessie594

: Webmaster google tools show me duplicate content on the same page after removed the php extention When i use the option Fetch as Google... show me the follow problems duplicate content meta

@Jessie594

Posted in: #DuplicateContent #GoogleSearchConsole #Seo

When i use the option Fetch as Google... show me the follow problems

duplicate content meta title
the story of....
/lifestyle/serialul-scorpion-inspirat-dintr-o-poveste-adevarata-a-lui-walter-o-brien.php
/lifestyle/serialul-scorpion-inspirat-dintr-o-poveste-adevarata-a-lui-walter-o-brien

Descoperă topul 10 a celor mai friguroase locuri din lume
/travel/descopera-top-10-care-sunt-cele-mai-friguroase-locuri-din-lume.php
/travel/descopera-top-10-care-sunt-cele-mai-friguroase-locuri-din-lume


this fact happened after i removed the php extention... useing the htaccess
#remove the php extension
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ .php [NC,L]

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Jessie594

2 Comments

Sorted by latest first Latest Oldest Best

 

@Annie201

I have a far simpler solution that allows you to maintain user friendliness of your URLs. Here's the .htaccess code:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*).php/?$ [NC]
RewriteRule ^(.*)/?$ /? [R=301,L]


The idea is, any guest trying to access anything on the domain that ends in .php (regardless of the case of the extension) with or without the trailing slash will be redirected to the homepage. I use this idea on my site to make potential hackers become angry.

I then index the friendly URLs without the file extensions with google, then all is good to go. zero duplicate content issues.

Only caveat with my method is if you have numerous of php files where the URLs (one with and one without the php extension) return exactly the same content and the php files never get updated, then my method will cause guests who access the site with the php extension to start over at the home page.

Then again, if you post news on your homepage and advertise updated sections (updated urls) of your site to your guests via the homepage and they naturally visit your homepage first, then my idea would be perfect.

The point is, just make sure that when two URLs return the exact same content that at least one of these conditions is true:


One URL returns a redirect page which sends the user to the other URL.
The URL that is the duplicate copy of the page has a <link rel="canonical" href="x"> in its HTML code. "x" is replaced with the URL of the original copy of the page.
The URL that is the copy has a <meta name="robots" content="noindex"> in its HTML code. I tend to use this often.

10% popularity Vote Up Vote Down


 

@Jamie184

When you change an existing URL structure you need to redirect the old URLs (that have probably been indexed and linked to) to the new URLs. (For the benefit of SEO and user experience.)

In your case the old URLs (with a .php extension) - that have been indexed - are still accessible and return the same content as the URL without the .php extension. So, you have duplicate content - two different URLs that return the same content.

Your existing directives internally rewrite the extensionless URL to the same URL but with a .php extension. Before these directives you need to externally redirect any requests for .php files to the extensionless URL. However, you need to be careful of a rewrite loop. In order to prevent a rewrite loop, you can check against THE_REQUEST (which only ever contains the URL of the initial request). For example:

RewriteEngine On

# Redirect old URLs to new
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} .*.php HTTP/
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule (.*).php$ / [R=301,L]


The above says, for all requested URLs that end in .php that exist as an actual file then redirect to the same URL less the .php extension.

Followed by your existing directives:

# Rewrite new (extensionless) URLs to the actual file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ .php [L]


There is no need to escape the dot (.) inside a character class. Inside a character class, a dot is a literal dot. I've removed the NC flag which seemed to be superfluous. (I've also changed your comment... those directives don't "remove the php extension", they add it back! You have presumably already removed the .php extension in the links in your application, otherwise your site won't be working right now.)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme