Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess what did I miss

sample included

     
3:56 pm on May 6, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 7, 2003
posts:105
votes: 0


I am tring to set up some 301s and 410s this code below works
for URL
www.mysite.com?Detail=News&Department= It shows the 404
but for URL
www.mysite.com?Detail=News&Department=66 it is not going to the redirect.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^Detail=News&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=About&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=Contact&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=Catalog&Department=$ [OR]
RewriteCond %{QUERY_STRING} ^Detail=Login&Department=$
RewriteRule ^(index\.php)?$ - [G]

RewriteCond %{QUERY_STRING} ^Detail=News&Department=66$
RewriteRule [R,L] (http://www.mysite.com)

5:27 pm on May 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


mikemcs,

By ending each pattern with an end anchor "$", you are telling mod_rewrite to match that exact string and only that exact string.

Reference: [etext.lib.virginia.edu...]

Also, this last Rule was backwards... should be:

RewriteRule .* [mysite.com...] [R,L]

HTH,
Jim

5:29 pm on May 6, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 7, 2003
posts:105
votes: 0


well in a sense that is what I want to do. I want to empty (Department=) to produce a 404 but the (Department=66) to receive a redirect to the index page.
5:39 pm on May 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


mikemcs,

The corrected Rule I posted still includes the default 302-Moved Temporarily redirect. This will not update, nor will it remove, the old URL from search engines. Is that the desired action?

Jim

5:46 pm on May 6, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 7, 2003
posts:105
votes: 0


Yes, I Had a problem with too many variables in my Url's so I reworte the site using more directories to control the content. a url
www.mysite.com?Detail=Catalog&Department=66
is now under
www.mysite.com/CCS/Catalog.php

I want to update and removed old URLS from search engines (Google)

5:53 pm on May 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


mikemcs,

In that case, you'd be better off with custom 404 and 410 error documents, each containing a link either to a site map or to your home page. If you return anything other than a 404-Not Found or 410-Gone status, the SEs won't remove the old URLs.

Jim

5:59 pm on May 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


... And to make Department 66 go away and replace it with your index page, use this:

RewriteCond %{QUERY_STRING} ^Detail=News&Department=66$
RewriteRule ^(index\.php)?$ [mysite.com...] [R=301,L]

Jim

6:16 pm on May 6, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 7, 2003
posts:105
votes: 0


Iím a bit confused (and new). If I want to clean out the Search Engine I should use a custom 404 or 410, but I should also use a redirect:

RewriteCond %{QUERY_STRING} ^Detail=News&Department=66$
RewriteRule ^(index\.php)?$ [mysite.com...] [R=301,L]

How can I use both? If I redirect with .htaccess then how would the bots see the 404?

6:28 pm on May 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


mikemcs,

If you have a direct replacement for a page, use a 301. The old URL will be replaced with the new one.

If there is no direct replacement for a given page, use a 410 - or a 404 if you have to - and redirect via ErrorDocument to a custom error page containing links to your home page and/or a site index page. These pages will be removed from the index, but visitors will still be able to find what they're looking for through the index page or site map.

You can define custom error documents using the ErrorDccument [httpd.apache.org] directive:


ErrorDocument 410 /this_page_is_gone.html

Do not use a full URL for the replacement page. Use a local path as shown. If a full URL is specified, the server will return a 302-Moved Temporarily response code, which defeats the purpose entirely.

The ErrorDocument defined for 410 will be invoked by your rules which include the [G] (Gone) flag.

You've got 99% of everything right - Just figure out how you want to handle each specific page you've removed.

Jim

6:44 pm on May 6, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 7, 2003
posts:105
votes: 0


Thanks Jim,
I did this and the redirect did go to the index page but it didnít change the URL in the address bar is this ok? Will google still drop the old address and replace it with the new on in its index? Would I be better off 404ing all of the pages (about 20 of them 90% of the site) and just let google reindex all the new pages with Fresh/Deep bot from the links on the indexpage which has not changed?
6:47 pm on May 6, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 7, 2003
posts:105
votes: 0


well now that I re look at it, The URL did change but it added the varibles back on to the new address.

I am still curious about if 404ing all the pages is the way to go.

7:14 pm on May 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


mikemcs,

I recommend that you use a 410 for pages you know are gone, and reserve 404 for unexpected problems. It makes sorting out your log files much easier.

Use the WebmasterWorld Server Header Checker [webmasterworld.com] to check your 'dead' page URLs. If you see a 410 or 404 response, that page will be dropped by the search engines. If you see a 301 response, that URL will be replaced with the new one. If you see a 302, then the search engine will do nothing except index the new page contents using the old URL.

Jim