homepage Welcome to WebmasterWorld Guest from 54.205.207.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

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



 
Msg#: 4423599 posted 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

 

peterz



 
Msg#: 4423599 posted 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]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4423599 posted 5:20 pm on Mar 1, 2012 (gmt 0)

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.

lucy24

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



 
Msg#: 4423599 posted 9:24 pm on Mar 1, 2012 (gmt 0)

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.

Mister206



 
Msg#: 4423599 posted 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?

Mister206



 
Msg#: 4423599 posted 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.

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4423599 posted 11:11 pm on Mar 1, 2012 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved