Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: [1] 2 3 4

Author Topic: [MOD] Avoiding duplicate content (trailing slash issue)  (Read 14939 times)

Joost

  • Guest
[MOD] Avoiding duplicate content (trailing slash issue)
« on: July 26, 2008, 11:45:59 PM »

Thanks to funlw65 the code is updated

sNews shows identical content regardless whether a requested url ends with a slash or not.
If this requests returns content:
http;//booptrap.com/category/
This one returns the same:
http;//booptrap.com/category
So whenever a site links to an sNews driven site, omiting the trailing slash, Google will probably mark that as duplicate content.

Using .htaccess it is possible to let sNews redirect(permanent, 301) urls without trailing slashes.

Here is the rewrite rule replacement for .htaccess. You will have to edit #RewriteBase /sNews16 as usual.

Quote
RewriteEngine On
#RewriteBase /sNews16
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ index.php?category=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1/ [R=301,L]


... And here is the old version, which simply returns a "Page not found message"

Quote
RewriteEngine On
#RewriteBase /sNews16
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ index.php?category=$1 [L]
« Last Edit: July 27, 2008, 07:50:50 PM by Joost »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #1 on: July 27, 2008, 12:30:39 AM »

Oho Joost!
I just wanted to post  a reply in Suggestions forums, to support Sven's request.
Thank you very much, K++
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #2 on: July 27, 2008, 09:38:14 AM »

Hi fellows.
As usual, I don't get it at all.
What should be done exactly. ???
« Last Edit: July 27, 2008, 09:40:55 AM by Sven »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #3 on: July 27, 2008, 09:54:44 AM »

Well, for now, the link

http;//sitename.com/category
will direct you to a 404
and http;//sitename.com/category/ will work as expected
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #4 on: July 27, 2008, 10:04:58 AM »

 ???

RewriteEngine On
#RewriteBase /sNews16
mine is:
Quote
RewriteEngine On
#
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
(...)
Quote
#RewriteBase /database
gives an internal error (500).

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #5 on: July 27, 2008, 10:13:30 AM »

And if you let it at it is?
It counts only what is after it because you don't have snews under a sub-folder....

edit:
RewriteBase can remain as it is on your file
« Last Edit: July 27, 2008, 10:17:45 AM by funlw65 »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #6 on: July 27, 2008, 10:24:41 AM »

It counts only what is after it because you don't have snews under a sub-folder....
okey. Got it now. Thanks pal. ;)

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #7 on: July 27, 2008, 05:05:02 PM »

Joost,
What about this?

Links without trailing slashes will be redirected (301) to links with trailing slashes. Of course, this will affect tag words which don't need trailing slash at the end but maybe this can be resolved inside code, not looked yet into...
I think tag case can be managed as in examples from that page....

What you think?

------------------------
EDIT:
The next rule for your already written rules can be this?
RewriteRule ^(.*)$ $1/ [L,R=301]
This way, all links without trailing slash will be redirect to one with trailing slash ... is working on my localhost but I'm not expert....

If this can meet your approval, can be:
RewriteEngine On
#RewriteBase /sNews16
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ index.php?category=$1 [L]
RewriteRule ^(.+)$ $1/ [L,R=301]


« Last Edit: July 27, 2008, 05:48:55 PM by funlw65 »
Logged

Joost

  • Guest
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #8 on: July 27, 2008, 06:55:47 PM »

I am not an expert either. However, logic and common sense, usual is my salvation(amen) ;).
It seems we both have different server configurations.
I adjusted your code, (which is by the way, far better then the code I've tried earlier today) to this:

RewriteEngine On
#RewriteBase /sNews16
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ index.php?category=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1/ [R=301,L]

I needed the extra line, to prevent .htaccess from adding an extra slash. The red line tells the server only to add slashes if it is not a directory.
I've tested yours and mine like this:
I've created a testmap, containing an index.html and somefile.html. I also have a somefile.html in the same directory as snews. That way, I am able to test all kinds of request like:

testmap/
testmap
testmap/somefile.html
somefile.html

Maybe you can do some similar testing on your local install?
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #9 on: July 27, 2008, 07:12:57 PM »

Is working also with that red line on my localhost
Logged

Joost

  • Guest
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #10 on: July 27, 2008, 07:28:01 PM »

Is working also with that red line on my localhost

Well done funlw65. :)

Quote from: Nasty forum
An Error Has Occurred!
Sorry, you can't repeat a karma action without waiting 1 hours.
:'(
« Last Edit: July 27, 2008, 07:30:08 PM by Joost »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #11 on: July 27, 2008, 07:41:24 PM »

 ;D Thank you Joost, is ok with only one :)
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #12 on: July 28, 2008, 06:34:00 PM »

Hello Big Indians
you're talking Apache to me. ???
Now my .htaccess is very so diffrent:
Quote
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) $1 [L]
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)/$ $1 [R=301,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule tag/(.*)$ index.php?search=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?category=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z_]+)/([^/]+) index.php?category=$1&title=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z_]+)/([^/]+)/([^/]+)/ index.php?category=$1&title=$2&commentspage=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_-]+)/([0-9]+)/ index.php?category=$1 articlespage=$2 [L]
Do I have to change something? :P

Joost

  • Guest
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #13 on: July 28, 2008, 08:03:01 PM »

Do I have to change something? :P

I am not sure what code your showing.  ??? It might include modified code to you need to run the site.
Anyway, the code that's published in the first post is the full monty. It meant to replace the .htaccess that's running a default installation.
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Avoiding duplicate content (trailing slash issue)
« Reply #14 on: July 29, 2008, 07:39:23 AM »

Bloody Alzeimer! I can't remember when and why I changed it! :-\
Pages: [1] 2 3 4