Loading ...
Sorry, an error occurred while loading the content.

Re: treating same file in two different directories as one

Expand Messages
  • neobot85
    Thank you Enric! It worked exactly as I wanted. =) I appreciate your help.
    Message 1 of 5 , Jun 20 5:44 AM
    • 0 Attachment
      Thank you Enric! It worked exactly as I wanted. =)

      I appreciate your help.


      --- In webalizer@yahoogroups.com, Enric Naval <enventa2000@y...> wrote:
      > The last one, I promise.
      >
      > RewriteEngine On
      > RewriteCond %{QUERY_STRING} type=([^&]+)&(.*)
      > RewriteRule ^/viewactivity/(.+)\.jsp
      > /%1/viewactivity.jsp?eid=$1%2 [L]
      > RewriteCond %{QUERY_STRING} type=(.*)
      > RewriteRule ^/viewactivity/(.+)\.jsp
      > /%1/viewactivity.jsp?eid=$1 [L]
      > RewriteCond %{QUERY_STRING} eid=([^&]+)&(.*)
      > RewriteRule ^/(.+)/viewactivity.jsp
      > /viewactivity/%1.jsp?type=$1&%2 [R=301,L]
      > RewriteCond %{QUERY_STRING} eid=(.*)
      > RewriteRule ^/(.+)/viewactivity.jsp
      > /viewactivity/%1.jsp?type=$1 [R=301,L]
      >
      >
      > It redirects from ...
      >
      > /kids/viewactivity.jsp?eid=222&other=world
      >
      > ... to ...
      >
      > /viewactivity/222.jsp?type=kids&other=world
      >
      >
      >
      > Now the looooong explanation: this does everything I
      > said, and preserves the query string that goes after
      > type=xxxx and eid=xxxxx. "([^&]+)" means to match
      > anything until you hit a "&" character and group it
      > inside "%1". There are two groups of RewriteCond, the
      > only difference is the "([^&]+)&(.*)" at the end. The
      > first tells apache to stop before the first "&" and
      > then forcefully find a "&" character and group
      > everything after the "&" in "%2". All matching visits
      > matching the second line has no "&", so there is only
      > one parameter in the query string, so you can dump
      > everything inside "%1" using "(.*)".
      >
      >
      > --- Enric Naval <enventa2000@y...> wrote:
      >
      > > Sorry, this didn't do exactly what you were asking
      > > for, and the apache code was wrong, because I didn't
      > > match correctly the query string :( I hope this time
      > > it's correct.
      > >
      > > To get webalizer to group correctly you have to
      > > apply
      > > a more complicated rule (the RewriteRule lines are
      > > in
      > > one single line. I have cut it in half to fit the
      > > message width):
      > >
      > > RewriteEngine On
      > > RewriteCond %{QUERY_STRING} ^type=(.*)
      > > RewriteRule ^/viewactivity/(.+)\.jsp
      > > /%1/viewactivity.jsp?eid=$1 [L]
      > >
      > > This redirects transparently from ...
      > >
      > > www.domain.com/viewactivity/222.jsp?type=parents
      > >
      > > ... to ...
      > >
      > > www.domain.com/parents/viewactivity.jsp?eid=222
      > >
      > > (notice how "kids" and "parents" have become a data
      > > you send in the query string, instead of being
      > > inside
      > > the url. You have to update all links in your
      > > website
      > > acordingly)
      > >
      > > In webalizer all activities with the same "eid" will
      > > now appear together, with no extra configuration.
      > >
      > >
      > > If you do this outside a <Directory> container, then
      > > inside your <Directory> container you have to put:
      > >
      > > RewriteEngine On
      > > RewriteOptions inherit
      > >
      > > So that apache will allow that directory to use the
      > > rewrite engine.
      > >
      > > The "%1" is the first "(.+)" or "(.*)" from the
      > > RewriteCond, and the "$1" is the first "(.+)" or
      > > "(.*)" from the first part of the RewriteRule line.
      > > You can later add %2, %3, etc. The "^" means "start
      > > of
      > > line"
      > >
      > >
      > > Now, you will have people still going to the old
      > > adresses, so you want to redirect them to the "new"
      > > addresses. You would then add this:
      > >
      > > RewriteEngine On
      > > RewriteCond %{QUERY_STRING} ^type=(.*)
      > > RewriteRule ^/viewactivity/(.+)\.jsp
      > > /%1/viewactivity.jsp?eid=$1 [L]
      > > RewriteCond %{QUERY_STRING} ^eid=(.*)
      > > RewriteRule ^/(.+)/viewactivity.jsp
      > > /viewactivity/%1.jsp?type=$1 [R=301,L]
      > >
      > > In this case we want to let the visitors know that
      > > they are being redirected to the "new" place, so we
      > > send a 301 (permanent) redirection.
      > >
      > > This way, also, the search engines won't penalize
      > > you
      > > because of having duplicate content
      > > ("viewactivity/222.jsp" now has the same content as
      > > "viewactivity.jsp?eid=222", and you would receive a
      > > penalization because the engine thinks that you are
      > > trying to fill it with duplicate content)
      > >
      > >
      > > Please let me know if it works for you, or if you
      > > find
      > > some error in the code.
      > >
      > > If you need to add more items in the query string,
      > > then you'll need even more RewriteRule lines:
      > >
      > >
      > > RewriteEngine On
      > > RewriteCond %{QUERY_STRING} ^type=(.+)&
      > > RewriteRule ^/viewactivity/(.+)\.jsp
      > > /%1/viewactivity.jsp?eid=$1 [L]
      > > RewriteCond %{QUERY_STRING} ^type=(.*)
      > > RewriteRule ^/viewactivity/(.+)\.jsp
      > > /%1/viewactivity.jsp?eid=$1 [L]
      > > RewriteCond %{QUERY_STRING} ^eid=(.+)&
      > > RewriteRule ^/(.+)/viewactivity.jsp
      > > /viewactivity/%1.jsp?type=$1 [R=301,L]
      > > RewriteCond %{QUERY_STRING} ^eid=(.*)
      > > RewriteRule ^/(.+)/viewactivity.jsp
      > > /viewactivity/%1.jsp?type=$1 [R=301,L]
      > >
      > >
      > >
      > >
      > > --- Enric Naval <enventa2000@y...> wrote:
      > >
      > > > I suggest that you use the ReWriteEngine in the
      > > > apache
      > > > server (I'm not sure whether you have to use "\."
      > > or
      > > > "." )
      > > >
      > > > RewriteEngine On
      > > > RewriteRule ^/parents/viewactivity/(.+)\.jsp
      > > > /parents/viewactivity.jsp?eid=$1 [L]
      > > > RewriteRule ^/kids/viewactivity/(.+)\.jsp
      > > > /kids/viewactivity.jsp?eid=$1 [L]
      > > >
      > > > This way, when you visit:
      > > >
      > > > www.domain.com/parents/viewactivity/222.jsp
      > > >
      > > > you get invisibily redirected to:
      > > >
      > > > www.domain.com/parents/viewactivity.jsp?eid=222
      > > >
      > > > You then make all your pages to link to
      > > > viewactivity/xxx.jsp, and your users will never
      > > > notice
      > > > they are using a dynamic page.
      > > >
      > > > The [L] is to tell apache to stop loking for more
      > > > RewriteRules and send already the answer to the
      > > > visitor. To show the redirection to the visitors,
      > > > you
      > > > add [R] in this way: [R,L]. You probably don't
      > > want
      > > > to
      > > > use [R].
      > > >
      > > > Also, very important. BY DOING THIS YOU GET A
      > > > GREATER
      > > > PAGERANK IN GOOGLE AND THE SPIDERS WILL VISIT MORE
      > > > YOUR PAGE. I used this in the pdf files for a
      > > > congress, and I doubled the visits to the page
      > > > overnight. The spiders are deceived into believing
      > > > that you are giving them static content, which
      > > they
      > > > like better than dynamic content. Also, remember
      > > to
      > > > use normal links instead of a submit button in a
      > > > from
      > > > or a javascript code.
      > > >
      > > >
      > > >
      > > > If you can't change that and you MUST use
      > > webalizer
      > > > to
      > > > do this, then I believe it is done this way.
      > > >
      > > > First you will need to add "?" to the isurlchar
      > > > function and recompile webalizer (otherwise, the
      > > > ?id=xxx part will be cut away by webalizer). Also,
      > > > webalizer will then not be able to find which
      > > search
      > > > strings have been used by visitors from the search
      > > > engines.
      > > >
      > > > GroupURL viewactivity.jsp?eid=222
      > > > viewactivity.jsp?eid=222
      > > > HideURL viewactivity.jsp?eid=222
      > > >
      > > > You'll have to put all of them one by one.
      > > >
      > > >
      > > > --- neobot85 <ngb2@r...> wrote:
      > > >
      > > > > Hi,
      > > > >
      > > > > I'm helping develop a site that has two
      > > different
      > > > > interfaces - a
      > > > > parents and a kids. The site is essentially
      > > > > identical in both
      > > > > interfaces, except for some style sheet changes
      > > -
      > > > > there are just a
      > > > > different set of pages in two directories.
      > > > >
      > > > > The site lists activities through a page called
      > > > > viewactivity.jsp.....so let's say we wanted to
      > > > view
      > > > > activity #222 we
      > > > > would go to viewactivity.jsp?eid=222.
      > > > >
      > > > > Now, what we'd like to do is display viewing an
      > > > > activity as one hit,
      > > > > regardless of which interface we're on.
      > > > >
      > > > > So, for example, we wouldn't want:
      > > > >
      > > > > /parents/viewactivity.jsp?eid=222 25
      > > > > /kids/viewactivity.jsp?eid=222 25
      > > > >
      > > > > to show up (as it does now). We'd like
      > > > >
      > > > > viewactivity.jsp?eid=222 50
      > > > >
      > > > > with the number of counts for the two different
      > > > > directories combined.
      > > > >
      > > > > Is there any way to do this?
      > > > >
      > > > > Thanks for any suggestions!
      > > > >
      > > > >
      > > > >
      > > >
      > > >
      > > > Enric Naval
      > > > Estudiante de Informática de Gestión en la Udl
      > > > (Lleida)
      > > > GRIHO webalizer.conf
      > > > http://griho.udl.es/webalizer/webalizer.conf.txt
      > > >
      > > > __________________________________________________
      > > > Do You Yahoo!?
      > > > Tired of spam? Yahoo! Mail has the best spam
      > > > protection around
      > > > http://mail.yahoo.com
      > >
      > >
      > > Enric Naval
      > > Estudiante de Informática de Gestión en la Udl
      > > (Lleida)
      > > GRIHO webalizer.conf
      > > http://griho.udl.es/webalizer/webalizer.conf.txt
      > >
      > > __________________________________________________
      > > Do You Yahoo!?
      > > Tired of spam? Yahoo! Mail has the best spam
      > > protection around
      > > http://mail.yahoo.com
      > >
      >
      >
      > Enric Naval
      > Estudiante de Informática de Gestión en la Udl (Lleida)
      > GRIHO webalizer.conf
      > http://griho.udl.es/webalizer/webalizer.conf.txt
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Tired of spam? Yahoo! Mail has the best spam protection around
      > http://mail.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.