[Lift] Re: Still confused about redirects

2009-01-24 Thread Tim Perrett

Chas,

As it happens, I need to do this also. For me, im porting a rails app,
so dont have the .html issues and im doing case by case redirects. So,
I have something like:

LiftRules.dispatch.prepend {
  case r @ Req(about :: Nil, , _) = () = Full
(PermRedirectResponse(/about-us,r))
}

However, if you want to redirect all your html pages back to the
index, you'd need something like:

LiftRules.dispatch.prepend {
  case r @ Req(page, html, _) = () = Full(PermRedirectResponse
(/,r))
}

Does that make sense?

Cheers, Tim

On Jan 24, 3:30 am, Charles F. Munat c...@munat.com wrote:
 Thanks! That helps. I'll try to figure it out.

 Chas.

 Marius wrote:
  LiftRules.prepend.dispatch is the right way.

  You pattern-match for *.html and return a PermRedirectResponse.

  Br's,
  Marius

  On Jan 23, 3:05 am, Charles F. Munat c...@munat.com wrote:
  I'm trying to do something dead simple, so it's impossible, of course.

  I have some legacy pages that don't exist anymore, and I want to send
  permanent (301) redirects to the browser. For example:

  Redirect permanent /thebook.htmlhttp://mysite.com/the_book/

  The above should work in my vhosts.d conf file, but, of course, it
  doesn't. Have tried it 50 ways.

  Searched for information about how to do redirects in Jetty: no joy.

  David gave me a hint some time ago using LiftRules.prepend.dispatch, but
  I'm too stupid to understand it.

  What I *really* want is for any request to any *.html page NOT
  index.html to go to the home page. Or, I'd be happy to just provide a
  list of from and to paths and have some code that does the redirects.
  This seems like a useful feature since my Lift sites will often replace
  legacy sites and it would be nice to be able to set up a list of old
  page - new page and just have the redirects go out (maybe with the
  option of permanent or temporary).

  Anyone know how to do this that can explain it in kindergarten terms? My
  brain is really fried today.

  Thanks!
  Chas.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Still confused about redirects

2009-01-24 Thread Charles F. Munat

Yeah, except I'm concerned that if I do this, I'll end up with loops (or 
at least requests for index.html will be redirected). All my pages are 
index.html, and all the pages I need to redirect from are not. So I 
intended to do a regex that grabbed everything that ended in html but 
was not index.html (except that I'm having a hell of a time writing that 
regex, so I'm just doing a list of pages to redirect).

Anyway, this helps a lot. So if I want to redirect thebook.html to 
/the_book/ I would do this:

LiftRules.dispatch.prepend {
   case r @ Req(thebook :: Nil, html, _) = () = Full(
 PermRedirectResponse(/the_book, r))
}

Right?

Chas.

Tim Perrett wrote:
 Chas,
 
 As it happens, I need to do this also. For me, im porting a rails app,
 so dont have the .html issues and im doing case by case redirects. So,
 I have something like:
 
 LiftRules.dispatch.prepend {
   case r @ Req(about :: Nil, , _) = () = Full
 (PermRedirectResponse(/about-us,r))
 }
 
 However, if you want to redirect all your html pages back to the
 index, you'd need something like:
 
 LiftRules.dispatch.prepend {
   case r @ Req(page, html, _) = () = Full(PermRedirectResponse
 (/,r))
 }
 
 Does that make sense?
 
 Cheers, Tim
 
 On Jan 24, 3:30 am, Charles F. Munat c...@munat.com wrote:
 Thanks! That helps. I'll try to figure it out.

 Chas.

 Marius wrote:
 LiftRules.prepend.dispatch is the right way.
 You pattern-match for *.html and return a PermRedirectResponse.
 Br's,
 Marius
 On Jan 23, 3:05 am, Charles F. Munat c...@munat.com wrote:
 I'm trying to do something dead simple, so it's impossible, of course.
 I have some legacy pages that don't exist anymore, and I want to send
 permanent (301) redirects to the browser. For example:
 Redirect permanent /thebook.htmlhttp://mysite.com/the_book/
 The above should work in my vhosts.d conf file, but, of course, it
 doesn't. Have tried it 50 ways.
 Searched for information about how to do redirects in Jetty: no joy.
 David gave me a hint some time ago using LiftRules.prepend.dispatch, but
 I'm too stupid to understand it.
 What I *really* want is for any request to any *.html page NOT
 index.html to go to the home page. Or, I'd be happy to just provide a
 list of from and to paths and have some code that does the redirects.
 This seems like a useful feature since my Lift sites will often replace
 legacy sites and it would be nice to be able to set up a list of old
 page - new page and just have the redirects go out (maybe with the
 option of permanent or temporary).
 Anyone know how to do this that can explain it in kindergarten terms? My
 brain is really fried today.
 Thanks!
 Chas.
  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Still confused about redirects

2009-01-24 Thread Tim Perrett

When you say all your pages are index.html, how do you mean? if your
file is index.html, in lift the URI would be /index right?


 Anyway, this helps a lot. So if I want to redirect thebook.html to
 /the_book/ I would do this:

 LiftRules.dispatch.prepend {
    case r @ Req(thebook :: Nil, html, _) = () = Full(
      PermRedirectResponse(/the_book, r))


Correct :-)



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Still confused about redirects

2009-01-24 Thread Charles F. Munat

All my templates are index.html. I use the folder name. And I never call 
them by index (I rewrote the Menu functions to avoid that). So I call 
/the_book/ and I get /the_book/index.html. But if someone entered 
/the_book/index.html, I'd still want it to work.

But you've made me realize that this might work:

LiftRules.dispatch.prepend {
   case r @ Req(page :: Nil, html, _) = if (page != index) =
Full(PermRedirectResponse(/, r))
}

That said, using this one I give up specific redirects in favor of 
sending everything to the home page. I think I like the other one better.

Thanks for all your help!

Chas.

Tim Perrett wrote:
 When you say all your pages are index.html, how do you mean? if your
 file is index.html, in lift the URI would be /index right?
 
 
 Anyway, this helps a lot. So if I want to redirect thebook.html to
 /the_book/ I would do this:

 LiftRules.dispatch.prepend {
case r @ Req(thebook :: Nil, html, _) = () = Full(
  PermRedirectResponse(/the_book, r))

 
 Correct :-)
 
 
 
  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Still confused about redirects

2009-01-24 Thread David Pollak
Charles,

Place the following lines in Boot.scala:

LiftRules.passNotFoundToChain = false
LiftRules.uriNotFound.prepend {
  case (r, _) = PermRedirectResponse(/, r)
}

This will work in 0.11-SNAPSHOT (there was a bug in 0.10 that prevents it
from working).

Any URL not found will be redirected to /.

Please wait an hour for the fix to propagate through Hudson and
scala-tools.org.

Thanks,

David

On Sat, Jan 24, 2009 at 11:35 AM, Charles F. Munat c...@munat.com wrote:


 All my templates are index.html. I use the folder name. And I never call
 them by index (I rewrote the Menu functions to avoid that). So I call
 /the_book/ and I get /the_book/index.html. But if someone entered
 /the_book/index.html, I'd still want it to work.

 But you've made me realize that this might work:

 LiftRules.dispatch.prepend {
   case r @ Req(page :: Nil, html, _) = if (page != index) =
Full(PermRedirectResponse(/, r))
 }

 That said, using this one I give up specific redirects in favor of
 sending everything to the home page. I think I like the other one better.

 Thanks for all your help!

 Chas.

 Tim Perrett wrote:
  When you say all your pages are index.html, how do you mean? if your
  file is index.html, in lift the URI would be /index right?
 
 
  Anyway, this helps a lot. So if I want to redirect thebook.html to
  /the_book/ I would do this:
 
  LiftRules.dispatch.prepend {
 case r @ Req(thebook :: Nil, html, _) = () = Full(
   PermRedirectResponse(/the_book, r))
 
 
  Correct :-)
 
 
 
  

 



-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Still confused about redirects

2009-01-24 Thread Charles F. Munat

Ah, that's a clever idea.

Chas.

David Pollak wrote:
 Charles,
 
 Place the following lines in Boot.scala:
 
 LiftRules.passNotFoundToChain = false
 LiftRules.uriNotFound.prepend {
   case (r, _) = PermRedirectResponse(/, r)
 }
 
 This will work in 0.11-SNAPSHOT (there was a bug in 0.10 that prevents 
 it from working).
 
 Any URL not found will be redirected to /.
 
 Please wait an hour for the fix to propagate through Hudson and 
 scala-tools.org http://scala-tools.org.
 
 Thanks,
 
 David
 
 On Sat, Jan 24, 2009 at 11:35 AM, Charles F. Munat c...@munat.com 
 mailto:c...@munat.com wrote:
 
 
 All my templates are index.html. I use the folder name. And I never call
 them by index (I rewrote the Menu functions to avoid that). So I call
 /the_book/ and I get /the_book/index.html. But if someone entered
 /the_book/index.html, I'd still want it to work.
 
 But you've made me realize that this might work:
 
 LiftRules.dispatch.prepend {
   case r @ Req(page :: Nil, html, _) = if (page != index) =
Full(PermRedirectResponse(/, r))
 }
 
 That said, using this one I give up specific redirects in favor of
 sending everything to the home page. I think I like the other one
 better.
 
 Thanks for all your help!
 
 Chas.
 
 Tim Perrett wrote:
   When you say all your pages are index.html, how do you mean? if your
   file is index.html, in lift the URI would be /index right?
  
  
   Anyway, this helps a lot. So if I want to redirect thebook.html to
   /the_book/ I would do this:
  
   LiftRules.dispatch.prepend {
  case r @ Req(thebook :: Nil, html, _) = () = Full(
PermRedirectResponse(/the_book, r))
  
  
   Correct :-)
  
  
  
   
 
 
 
 
 
 -- 
 Lift, the simply functional web framework http://liftweb.net
 Collaborative Task Management http://much4.us
 Follow me: http://twitter.com/dpp
 Git some: http://github.com/dpp
 
  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Still confused about redirects

2009-01-24 Thread David Pollak
On Sat, Jan 24, 2009 at 2:32 PM, Charles F. Munat c...@munat.com wrote:


 Ah, that's a clever idea.


:-)




 Chas.

 David Pollak wrote:
  Charles,
 
  Place the following lines in Boot.scala:
 
  LiftRules.passNotFoundToChain = false
  LiftRules.uriNotFound.prepend {
case (r, _) = PermRedirectResponse(/, r)
  }
 
  This will work in 0.11-SNAPSHOT (there was a bug in 0.10 that prevents
  it from working).
 
  Any URL not found will be redirected to /.
 
  Please wait an hour for the fix to propagate through Hudson and
  scala-tools.org http://scala-tools.org.
 
  Thanks,
 
  David
 
  On Sat, Jan 24, 2009 at 11:35 AM, Charles F. Munat c...@munat.com
  mailto:c...@munat.com wrote:
 
 
  All my templates are index.html. I use the folder name. And I never
 call
  them by index (I rewrote the Menu functions to avoid that). So I call
  /the_book/ and I get /the_book/index.html. But if someone entered
  /the_book/index.html, I'd still want it to work.
 
  But you've made me realize that this might work:
 
  LiftRules.dispatch.prepend {
case r @ Req(page :: Nil, html, _) = if (page != index) =
 Full(PermRedirectResponse(/, r))
  }
 
  That said, using this one I give up specific redirects in favor of
  sending everything to the home page. I think I like the other one
  better.
 
  Thanks for all your help!
 
  Chas.
 
  Tim Perrett wrote:
When you say all your pages are index.html, how do you mean? if
 your
file is index.html, in lift the URI would be /index right?
   
   
Anyway, this helps a lot. So if I want to redirect thebook.html
 to
/the_book/ I would do this:
   
LiftRules.dispatch.prepend {
   case r @ Req(thebook :: Nil, html, _) = () = Full(
 PermRedirectResponse(/the_book, r))
   
   
Correct :-)
   
   
   

 
 
 
 
 
  --
  Lift, the simply functional web framework http://liftweb.net
  Collaborative Task Management http://much4.us
  Follow me: http://twitter.com/dpp
  Git some: http://github.com/dpp
 
  

 



-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Still confused about redirects

2009-01-23 Thread Charles F. Munat

Thanks! That helps. I'll try to figure it out.

Chas.

Marius wrote:
 LiftRules.prepend.dispatch is the right way.
 
 You pattern-match for *.html and return a PermRedirectResponse.
 
 Br's,
 Marius
 
 
 On Jan 23, 3:05 am, Charles F. Munat c...@munat.com wrote:
 I'm trying to do something dead simple, so it's impossible, of course.

 I have some legacy pages that don't exist anymore, and I want to send
 permanent (301) redirects to the browser. For example:

 Redirect permanent /thebook.htmlhttp://mysite.com/the_book/

 The above should work in my vhosts.d conf file, but, of course, it
 doesn't. Have tried it 50 ways.

 Searched for information about how to do redirects in Jetty: no joy.

 David gave me a hint some time ago using LiftRules.prepend.dispatch, but
 I'm too stupid to understand it.

 What I *really* want is for any request to any *.html page NOT
 index.html to go to the home page. Or, I'd be happy to just provide a
 list of from and to paths and have some code that does the redirects.
 This seems like a useful feature since my Lift sites will often replace
 legacy sites and it would be nice to be able to set up a list of old
 page - new page and just have the redirects go out (maybe with the
 option of permanent or temporary).

 Anyone know how to do this that can explain it in kindergarten terms? My
 brain is really fried today.

 Thanks!
 Chas.
  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---