homepage Welcome to WebmasterWorld Guest from 54.161.185.244
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess what did I miss
sample included
mikemcs

10+ Year Member



 
Msg#: 245 posted 3:56 pm on May 6, 2003 (gmt 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)

 

jdMorgan

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



 
Msg#: 245 posted 5:27 pm on May 6, 2003 (gmt 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

mikemcs

10+ Year Member



 
Msg#: 245 posted 5:29 pm on May 6, 2003 (gmt 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.

jdMorgan

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



 
Msg#: 245 posted 5:39 pm on May 6, 2003 (gmt 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

mikemcs

10+ Year Member



 
Msg#: 245 posted 5:46 pm on May 6, 2003 (gmt 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)

jdMorgan

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



 
Msg#: 245 posted 5:53 pm on May 6, 2003 (gmt 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

jdMorgan

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



 
Msg#: 245 posted 5:59 pm on May 6, 2003 (gmt 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

mikemcs

10+ Year Member



 
Msg#: 245 posted 6:16 pm on May 6, 2003 (gmt 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?

jdMorgan

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



 
Msg#: 245 posted 6:28 pm on May 6, 2003 (gmt 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

mikemcs

10+ Year Member



 
Msg#: 245 posted 6:44 pm on May 6, 2003 (gmt 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?

mikemcs

10+ Year Member



 
Msg#: 245 posted 6:47 pm on May 6, 2003 (gmt 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.

jdMorgan

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



 
Msg#: 245 posted 7:14 pm on May 6, 2003 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved