SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod rewrite - Google still contains old links - disappear old '?'

    here's my problem:

    http://www.google.com/search?q=site:...n&lr=&filter=0


    I do not want any of those links to show up on google anymore....

    here are my current rewrite:

    Code:
    Options -Indexes +SymLinksIfOwnerMatch
    RewriteEngine On
    
    RewriteRule ^about(/)?.*$ aboutXposure.php 
    RewriteRule ^about/contact.$ contactus.php
    RewriteRule ^legal(/)?.*$ XposurePolicy.php
    RewriteRule ^services(/)?.*$ content/services/services.php
    RewriteRule ^portfolio(/)?.*$ content/portfolio/portfolio.php

    I want a rule that redirect [R] or gives a 410 error [G] if url contains '?'
    Just so that next time google crawls my site... it trashes those links... which were active during the summer... before I rewrote ... since it doesn't get any errors google has kept those links as search results..


    here's my first attempt... however it isn't working.
    here is my thinking: '.' anything that follows and escape \?
    however this isn't working... anybody know what i can do
    RewriteRule ^.\?$ index.php [R]

  2. #2
    SitePoint Enthusiast mrsmiley's Avatar
    Join Date
    Jul 2004
    Location
    Melbourne
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try asking this in the Apache threads to see what those guys say. You could probably register the old files as permanently moved to the new location. I think its a 304 response? Blane wrote an article/blog on mod_write the other day which had something similar in it.

  3. #3
    SitePoint Enthusiast Viper_SB's Avatar
    Join Date
    Aug 2003
    Location
    Canada
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a 301 redirect try this on one of those pages
    PHP Code:
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.mysite.com/newlocation.php');
    header('Connection: close'); 

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mrsmiley:

    I wasn't aware that their is a section solely for apache... usually just in php or graphic section

    i will do..

    here is the article for any reading: http://www.sitepoint.com/blog-view.php?blogid=6

    thanks,





    Viper_SB

    thanks for clearing up the the error number
    I cannot use code you suggested because

    Code:
    RewriteRule ^services(/)?.*$ content/services/services.php
    RewriteRule ^portfolio(/)?.*$ content/portfolio/portfolio.php
    
    .
    it contains all the major api's for my site...navigation ..everything

    that why i have to look to see if
    Code:
    RewriteCond %{REQUEST_URI}    #if exist
    for following link a ^content/services/ services.php$   if so [R=301]
    this is specific to that url... however right now i'm trying to purge any links that may still exist so

    Code:
    RewriteCond %{REQUEST_URI}    #if exist
    for all site links ^.?$  if so [R=301]
    
    #that have a query string ? return error 301
    or a variation is what i'm looking for.... i'm new to url rewrites ... especially the RewriteCond ... although look like really powerful stuff .


    Once i figure it out... hopefully by the weekend I'll post my findings.
    Note: i'm not sure if RewriteCond %{REQUEST_URI} would be the right approach yet since it returns everything after your domain name...
    I'm thinking so since in php request url work like this:

    example if this is my site (this is something i'm building at work):
    http://aggieculture.tamu.edu/linuxTutorApp/index1.php


    request url will return:
    /linuxTutorApp/navigation.php?logout=

    were '?logout=' was present at the time so if i can check the value returned by request url for the character '?' then it would work.

  5. #5
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Solution

    K found time today to hack at this for another 3 hours... gosh such an easy solution ..

    Note: RewriteCon or Con(s) apply to the first rewrite rule it sees

    Code:
    RewriteCond %{QUERY_STRING} ^id(.*)$
    RewriteRule ^(.*)$ http://www.xposure.us/ [G,L]
    note: For those that do not know a query_string is anything after ? in a url
    so you cannot look for ? in the Query_String .. it contains stuff only after the ?


    example: www.xposure.us/index.php?
    will give me the index page

    www.xposure.us/index.php?id%$@#jkw0-3anthing else as long as query string contains id will give you gone message

    Code:
    RewriteCond %{QUERY_STRING} ^id(.*)$
    to this
    RewriteCond %{QUERY_STRING} ^(.*)$
    makes it non specific to query string containing id but to any query string...


    I didn't do the modification because its primary to purge the id's off the search engine.. and
    because eventually i will use the query string as cssgarden has
    http://www.csszengarden.com/?cssfile...083.css&page=0

    in xposure's portfolio section... Thanks for the comments.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •