Forum Moderators: phranque

Message Too Old, No Replies

Redirecting Old Wordpress Parameters

Problem with old wordpress parameters

         

lindsay25

9:57 pm on Oct 17, 2010 (gmt 0)

10+ Year Member



Hey Guys,

I've looked through many old threads but can't seem to find anything that works for us with this one. Played about with .htaccess quite a bit, but still nothings working. Also tried disabling this paramter in webmaster tools weeks ago, but it's still coming up!

Basically, we had wordpress installed, and after a major mess up, removed it completely. However google still finds links, and then indexes pages such as www.domain.com/?p=1477 .

None of these pages exist, and my current redirect just see's them load our main page www.domain.com, with the paramter present in the url .

I'd much prefer that the paramter "?p=" was completely removed, or sorted into a method where google doesn't see tonnes of old links to us that all now have the same title in the search results, flagging up some major duplicate content.

Hope this makes sense :D

Thanks guys,
Lindsay x

g1smd

11:17 pm on Oct 17, 2010 (gmt 0)

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




One or two lines of mod_Rewrite code should fix it.

What have you tried so far?

lindsay25

1:29 am on Oct 18, 2010 (gmt 0)

10+ Year Member



Well at the moment, i simply have a 301 redirect to our top domain, which of course is keeping the parameter in play, so while it makes these links to working content, it's unfortunately keeping the duplicate content with the added ?p= parameter in the urls.

What would you recommend for mod_Rewrite to sort this and clear out the ?p= all together?

jdMorgan

2:40 am on Oct 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, a 301 redirect implemented with mod_rewrite, testing for the presence of the query-string-part "p=" using a RewriteCond and including a "?" at the end of the RewriteRule substitution URL (which functions as an operator to clear the existing query) is all that is needed.

Jim

lindsay25

12:17 pm on Oct 18, 2010 (gmt 0)

10+ Year Member



Hey JDMorgan,

Right, that makes sense, but only to my limited htaccess knowledge. Can I now be really cheeky and ask you to demonstrate this. Sorry, i'm one of those people that's never sat and learned the actual coding for .htaccess, just usually googled and copied and pasted certain statements when needed :D

Sorry hehe. Any demonstration of this would be appreciated!

Lindsay x

jdMorgan

12:56 pm on Oct 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, to be forthright, the problem is that we don't do that here. It's not a sustainable approach with the very limited number of contributors we have, as explained in our Forum Charter [webmasterworld.com]. The Charter also contains links to the resources you'll need to get started. We operate on an "education-assistance" model because we are far short of the number of contributors needed to provide a "free world-wide coding service."

Also, this search [google.com] will turn up hundreds of prior threads, representing a substantial investment of volunteers' time.

I should also point out that it is critical that you completely understand any proposed solution. Because all sites are different and most sites change over time, it would be a liability for you to install server configuration code that you do not completely understand.

By making an attempt to solve this problem yourself and posting the results, you not only gain some familiarity with the tools and terminology, but take ownership of the problem and demonstrate exactly where our contributors need to focus to address problems and misunderstandings. This avoids a lot of repetitious posting and turns the thread into a discussion which will be potentially useful to many more people in the future.

Jim

lindsay25

2:07 am on Oct 20, 2010 (gmt 0)

10+ Year Member



Hi JD

Sure I understand and respesct that. Unfortunately, i've followed all your advice in the last post, and learned what each statement regarding RewriteCond/Rule etc means, but I'm still having trouble setting a rule that fully wipes out ?p= (or any query for that matter) on the end of our url.

To also add, the links, and structure of the removed content were that of the following:

domain.co.uk/schedule/?p=4241 (many different posts existed under a variety of numbers from 0-5000). They were never indexed as "index.php" then the query after, just the folder structure and then the "?p=" tag as shown above.

You helped a few others in some threads in that google search you mentioned, which was a great learning curve. I kept thinking, "almost got it!", but still the ?p= remains on the end of the url regardless of trying your own Mod_Rewrite code and then also starting from scratch and doing it myself!

I'm going nuts :D haha x

lindsay25

2:14 am on Oct 20, 2010 (gmt 0)

10+ Year Member



Actually JD,

I've gone back and edited something you mentioned a while ago in a thread.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /schedule/([^?]*)\?
RewriteRule .* http://www.example.co.uk/schedule/%1? [R=301,L]


Seems to do the trick! I think that's pretty clean code for what is required.

jdMorgan

12:56 pm on Oct 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That can be tweaked a bit more for efficiency and robustness:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /schedule(/[^?]*)?\?[^\ ]*\ HTTP/
RewriteRule ^schedule(/.*)?$ http://www.example.co.uk/schedule$1? [R=301,L]

This will detect and correct requests for
/schedule?p=nnn
/schedule/blah/?p=nnn
/schedule/blah?p=nnn

as well as for "/schedule/?" and "/schedule/?p=nnn"

In addition, the RewriteCond processing will now be skipped completely if the request is not for a "/schedule" URL-path, so it's less work for the server overall (See "Rule Processing" in the Apache mod_rewrite doc if that's not clear).

I'm glad you were able to get up to speed on this. Now you've got the knowledge to tweak and adjust the code if changes are needed or if any unforeseen problems arise. That's much better than having to depend on "the kindness of strangers" when there's a problem and/or your site is down...

Jim