skip to Main Content

I am trying to set up a few conditional redirects for a lighttpd installation on Ubuntu. I would like the following:

https://www.example.com/clients/xyz
https://www.example.com/admin/xyz

To pass through normally, but something like:

https://www.example.com/abc123

To redirect to the "index.php" page at the web root, where I will inspect and act on the "abc123" portion of the URL. I would like all redirects to retain the query parameters (if any).
I’m basically building a conditional router without having all requests hit "index.php".

Any assistance would be MUCH appreciated!

I read the documentation on the settings in "lighttpd.conf" regarding "mod_redirect" usage but I’m confused as to where to start.

2

Answers


  1. It’s a while since I used lighttpd, but you can match the specific ones you want using rewrite-once, then catch the rest with .* – e.g.

    $HTTP["host"] =~ "^www.example.com|example.com$" {
        url.rewrite-once = ( 
            "^/clients/(.*)" => "/clients/$1",
            "^/admin/(.*)" => "/admin/$1",
            "^/(.*)" => "/index.php/$1"
        )
    }
    
    Login or Signup to reply.
  2.     url.rewrite-once = ( 
            "^/(?:admin|clients)/" => "",  # pass through unmodified
            "" => "/index.php$0"           # catch all and send to /index.php
        )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search