Welcome to WebmasterWorld Guest from 54.162.227.136

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

My .htaccess file works but will it help me avoid duplicate content

     
2:35 pm on Mar 1, 2012 (gmt 0)



Hi All,

Here is a rewrite that works for extensionless urls and add the trailing slash. My 2 question are

1. will this also avoid duplicate content?

2. Also how do I test and see if there is any duplicate content?

Am I doing this correctly when all I want to do is write nice looking url's

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

Thanks in advance for an help
4:46 pm on Mar 1, 2012 (gmt 0)



Why do you think this should eliminate duplicate content? Maybe it would be helpful if you could explain what you want to do.

Regards

Peter

[edited by: eelixduppy at 10:07 pm (utc) on Mar 1, 2012]
[edit reason] no personal urls, please [/edit]

5:20 pm on Mar 1, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Add the [L] flag to every RewriteRule.

Change the order so that redirecting RewriteRules are listed before those that internally rewrite.

For redirecting rules, add the protocol and hostname to the rule target.

Add a blank line after every RewriteRule for code clarity.

URLs for pages should not end with a trailing slash. Your redirecting rule should have a RewriteCond looking at THE_REQUEST instead of REQUEST_URI. This will prevent an infinite redirect-rewrite loop.
9:24 pm on Mar 1, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



For redirecting rules, add the protocol and hostname to the rule target.

... especially if part of your goal is to eliminate Duplicate Content. Otherwise, people who arrive asking for www.example.com will end up getting www.example.com; people who ask for example.com will get example.com; sneaky people who ask for example.com:80 will walk away with example.com:80 and so on.

For "people" read "search engines" and there's your duplication.
11:08 pm on Mar 1, 2012 (gmt 0)



Thanks All

@Peterz. I dont have any that I know of I just dont want to create any.

@g1smd What is the [L] Flag? I think you understand what Im trying to do. Could you please post a example of what you mean?
11:10 pm on Mar 1, 2012 (gmt 0)



@lucy Im not sue I understand "add the protocol and hostname to the rule target." or "For "people" read "search engines" and there's your duplication. "

Im not really knowledgebale on this subject. I am a web designer but when to comes to apace servers (or any servers) Im a complete novice.
11:11 pm on Mar 1, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



[google.com...] ... site:webmasterworld.com/apache RewriteRule [L]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month