Forum Moderators: phranque

Message Too Old, No Replies

How to prevent duplicat content after mod_rewrite

can't do redirect....

         

JoaoJose

10:41 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



Hi everyone.

Some time ago I was in the process of changing my dynamic urls to static. [link]http://www.webmasterworld.com/forum92/3883.htm[/link]

The redirect wasn't working and I also had to stop due to more important things I had to do.

Today I picked this again and went a little bit further.

So I did some changes on my php script in order to fetch the page titles and put those titles on the urls.

After that I did the rewriting on htaccess and it works fine.

My problem now are the old urls. I canīt match anything as you can see....So what to do?

I thought of disallowing all those old urls on robots.txt but I will lose ranking for all dynamic pages (which make almost my entire site)....

Any thoughts?

jdMorgan

2:10 am on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JoaoJose,

> I canīt match anything as you can see[...]

I'm not sure what you mean here. Rewrite the static URLs to the dynamic URLs to invoke your script, and redirect the dynamic URLs to the static URLs. You'll have to use


RewriteCond %{THE_REQUEST} <METHOD>\ /<dynamic_URL_pattern\?<query_string_pattern>\ HTTP

to avoid an 'infinite' rewrite loop, but it usually works fine.

[added] See [webmasterworld.com...] message#2. [/added]

Jim

JoaoJose

9:23 am on Jul 22, 2005 (gmt 0)

10+ Year Member



Hi Jim, thanks for your reply.

My problem is that my pages are made by my visitors so I have no control over them, meaning it's not me who decides what title a page will have, so it's impossible for me to match the url on the rewrite rule.

Cheers

jdMorgan

2:31 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there *nothing* about the URLs that you can detect? I can't imagine you're allowing the user-content to be placed into static URLs that appear to reside in your root directory, so can't you store them into a 'special' subdirectory by adding something to the URL-path of user-generated files?

This won't answer your current problem, but will help going forward; Tag each user post with something that identifies it as such, then use mod_rewrite to detect the identifier and do the rewrite.

E.G. /user_post/2005072211291501/whatever_title_the user_picked.html

Here, you can detect "user_post/" as an indicator the the URL should be rewritten.

Jim

JoaoJose

5:25 pm on Jul 22, 2005 (gmt 0)

10+ Year Member



Hi Jim, first of all thanks again for your help.

People sell stuff on my site. We have widget1,2 and 3.

The new static url has offcourse a pattern that I can identify, if it hadn't I couldn't do the rewrite on the first place.

So what I have now is something like:

www.mysite.com/pagetitle-widget1-id.html

[bold]pagetitle is composed of:[/bold]

"make of the wigdet"-"model of the widget"-"description"

these are all database stored.

[id]

is a number that identifies the widget

So I may be missing something, then again I'm pretty new to this, but I can't see how to do a redirect....