Forum Moderators: phranque

Message Too Old, No Replies

Wordpress & Duplicate content .

Big problem number in rewrite in wordpress

         

leandre

8:02 am on Sep 8, 2008 (gmt 0)

10+ Year Member



Hello,

I have big big problem witch my blog in wordpress :

Good url :
http://www.example.com/toto/
http://www.example.com/toto/tata/
http://www.example.com/toto/tata/lolo/

Bad url :
http://www.example.com/toto/20/ = 200
http://www.example.com/toto/tata/43/ = 200
http://www.example.com/toto/tata/33/ = 200
http://www.example.com/toto/tata/lolo/88/ = 200

When you write number after last slash this is duplicate content :(

I test many solution but i dont find good solution.
If one people find me nice solution by .htaccess fore send 301 or 404 i paid 200usd by paypal

See you

g1smd

9:50 am on Sep 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do any of the real URLs ever contain numbers at the end?

If not, detect URLs that end with numbers and fail them.

[0-9] is used to detect the presence of numbers.

{2} or {1,4} is used to match a specific length or range of lengths.

leandre

1:07 pm on Sep 8, 2008 (gmt 0)

10+ Year Member



I try but it's not nice solution :(

RewriteCond %{REQUEST_URI} ^(.*)[0-9](.*)$
RewriteRule . http://www.example.com%1/%2 [R=301,L]

Actualy is ok for me but if im use :

www.example.com/2008/09/08/sample-post/ is doesnt work but this is good url

and this is bad url :

www.example.com/2008/09/08/sample-post/666/

g1smd

5:38 pm on Sep 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This will match with that:

^([0-9]{4})/([0-9]{2})/([0-9]{2})/([A-Z])/([0-9])/?

and allows for the trailing / to be optional.

If the numbers are at the end, and normal URLs never end with numbers, you can use this:

[0-9]/?$

leandre

11:02 pm on Sep 8, 2008 (gmt 0)

10+ Year Member



Sorry but this rule is doesnt work :

RewriteCond %{REQUEST_URI} ^([0-9]{4})/([0-9]{2})/([0-9]{2})/([A-Z])/([0-9])/?$
RewriteRule . http://www.example.com%1 [R=301,L]

And my normal urls never end with numbers. But i have this type of url

www.example.com/2008/09/08/sample-post/
www.example.com/7-sample-post/
www.example.com/page-toto/page-tata/page-titi/

g1smd

11:30 pm on Sep 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The %1 holds only "2008" as a value.

You'll need to bracket (another level) the bit you want to keep.

My example wasn't end anchored; I believe that it doesn't need to be.

jdMorgan

12:07 am on Sep 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



URL-paths in RewriteCond %{REQUEST_URI} patterns must start with a slash.
URL_path patterns in RewriteRules in .htaccess must not start with a slash.

But you don't need a RewriteCond anyway.


RewriteRule ^([0-9]{4}/[0-9]{2}/[0-9]{2}/[A-Z\-]/)[0-9]+/?$ http://www.example.com/$1 [NC,R=301,L]

I see you have strings like "= 200" in your early posts in this thread. The pattern shown here will not match those, since it matches only extra numbers at the end of the requested URL. You must be very very specific with examples of "good" and "bad" URLs, and the allowable variations of each. It is impossible to write code until the requirements are precisely defined.

Jim

leandre

12:49 am on Sep 9, 2008 (gmt 0)

10+ Year Member



Sorry g1smd & jdMorgan

All wordpress blog have a same problem

This is good url :
[wordpress.org...]
[wordpress.org...]
http://www.example.com/toto/tata/lolo/
http://www.example.com/2008/09/08/sample-post/

This is bad url :
[wordpress.org...]
[wordpress.org...]
[wordpress.org...]
http://www.example.com/toto/tata/lolo/12345/

When the url is finish by random number this is duplicate content and this is of all blog work on wordpress. But the number in url is good (Ex : 2008 & 09 & -262). The problem is final number (Ex : /777/ & /666/ & /98765/ & /12345/)

This is my .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On

# Problem number
RewriteRule ^([0-9]{4}/[0-9]{2}/[0-9]{2}/[A-Z\-]/)[0-9]+/?$ http://www.example.com/$1 [NC,R=301,L]

# Case sensitive
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ lcaseurl\.php\?url=\/$1 [L,NC]

</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

But this rule is doesent work :

RewriteRule ^([0-9]{4}/[0-9]{2}/[0-9]{2}/[A-Z\-]/)[0-9]+/?$ http://www.example.com/$1 [NC,R=301,L]

I test this solution :
RewriteRule ^(.*)[0-9](.*)$ http://www.example.com/$1 [NC,R=301,L]

But is not good solution because is broke good url witch number (Ex :http://wordpress.org/development/2008/05/birthday-party/) but is work for this bad url (http://www.example.com/toto/tata/lolo/12345/) :(

jdMorgan

3:03 am on Sep 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The pattern must match the requested URL.

In example.com/.htaccess:


RewriteRule ^(([a-z0-9_\-]/)+)[0-9]+/?$ http://www.example.com/$1 [NC,R=301,L]

This rule will remove the final numeric-only URL-path-part (with or without a trailing slash) from any URL that contains one or more URL-path-parts composed of letters, numbers, hyphens, or underscores only.

The only identifying features for the "bad" URL-path-part to be removed is that it is the final URL-path-part and that it is composed only of numbers.

Jim

leandre

11:41 am on Sep 9, 2008 (gmt 0)

10+ Year Member



Thank you but this rule is dosent work :(

g1smd

11:53 am on Sep 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



"Doesn't work" is too broad a description to convey any useful meaning.

What URL did you try?
What did you expect to happen?
How does that differ from what you expected?

leandre

12:23 pm on Sep 9, 2008 (gmt 0)

10+ Year Member



Hi try this :

http://www.example.com/toto/20/
http://www.example.com/toto/tata/43/
http://www.example.com/toto/tata/33/
http://www.example.com/toto/tata/lolo/88/

And i have no rewrite :(

jdMorgan

3:50 pm on Sep 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, I'm out of ideas. I suggest you hire a local expert who can sit down with you and figure this out. :(

Jim