Hi!
I'm new to lighty and have a problem with the configuration. I have set
up a redirect and a rewrite. Unfortunately the rewrite is always done
first preventing my redirect being executed.
Here is a simplified exaple:
url.redirect = (
"^/foo" => "http://www.somesite.com"
)
url.rewrite-once = (
"^/(.*)/?$" => "/action.php?id=$1",
)
As you can see the rewrite will match anything, thus preventing the
redirect to be executed. I real life both options contain some bigger
lists of rewrites and redirects but it all comes down to this: I need a
way to go through the redirects before the rewrites.
Can anyone give me a tip how to do this?
BTW. I read that module order matters but it seems not to make any
difference. This is my module list:
server.modules = (
"mod_redirect",
"mod_rewrite",
"mod_alias",
"mod_access",
"mod_auth",
"mod_fastcgi",
"mod_accesslog"
)
Andi
on 10.09.2006 19:32
on 10.02.2007 05:35
I have the same problem with you. Do you solve this? Or anyone can give me a solution?
on 05.05.2007 18:10
I was also having this problem and finally got an answer from user "weigon_". If your rewrite rule goes to "$0", then the URL will pass through. This is how you would fix your example: Andi wrote: > url.redirect = ( > "^/foo" => "http://www.somesite.com" > ) > > url.rewrite-once = ( > "^/(.*)/?$" => "/action.php?id=$1", > ) You would simply do this: url.redirect = ( "^/foo" => "http://www.somesite.com" ) url.rewrite-once = ( "^/foo" => "$0", "^/(.*)/?$" => "/action.php?id=$1", ) And then hits to /foo will pass through the rewrite and go onto the redirect. I am succesfully using this in my own configuration. Good luck! This thread is old, but it was one of the top hits when I was searching -- I hope someone else finds this helpful. I'm going to try editing the mod_rewrite wiki page. .:. brainsik

