Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Robert Simplicio, Simplicio Systems Inc., Professional Meditech NPR report writing, integration, and custom Magic & VMagic programming. http://www.simplicio.com

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

Common Lighttpd rewrite requests

More than anything, this is for my own reference, but also for the benefit of jordanbrock...

This comes courtesy http://www.cyberciti.biz/tips/lighttpd-redirect-www-domaincom-to-domain-com.html

For various reason you might want to redirect all traffic coming to www.domain.com to domain.com or vise versa.

This is essential if you want to maintained good structure for search engines (SEO) or to generate accurate stats.

Open your /etc/lighttpd/lighttpd.conf file:
# vi /etc/lighttpd/lighttpd.conf

Find your virtual domain section.

h4. Add following configuration directive if you want to redirect www.domain.com to domain.com

$HTTP["host"] =~ "^www\.(.*)" { url.redirect = ( "^/(.*)" => "http://%1/$1" ) }


h4. Add following configuration directive if you want to redirect domain.com to www.domain.com

$HTTP["host"] =~ "^domain\.com$" { url.redirect = ( "^/(.*)" => "http://www.domain.com/$1" ) }


Close and save the file. Restart the lighttpd web server:
# /etc/init.d/lighttpd restart

My Typo Lighttpd host conditional

$HTTP["host"] =~ "(typo|blog)\.simplicio\.(com|net|org)" {
server.document-root = "/home/rsimplicio/web/public/typo/"

url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
server.error-handler-404 = "/dispatch.fcgi"
server.indexfiles = ( "dispatch.fcgi")

fastcgi.server = ( ".fcgi" =>
( "Simplicio-typo" =>
(
"socket" => "/home/rsimplicio/web/lighttpd-typo-fcgi.socket",
"bin-path" => "/home/rsimplicio/web/public/typo/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => "production" ),
"max-load-per-proc" => 25,
"min-procs" => 1,
"max-procs" => 1,
"idle-timeout" => 60
)
)
)
}

Lighttpd conditional for subdomain

$HTTP["host"] =~ "(typo|blog)\.simplicio\.(com|net|org)" {
server.document-root = "/home/rsimplicio/web/public/typo/"

url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
  server.error-handler-404 = "/dispatch.fcgi" 
server.indexfiles = ( "dispatch.fcgi")

 fastcgi.server = ( ".fcgi" =>
   ( "Simplicio-typo" =>
        (
          "socket"   => "/home/rsimplicio/web/lighttpd-typo-fcgi.socket",
          "bin-path" => "/home/rsimplicio/web/public/typo/dispatch.fcgi",
          "bin-environment" => ( "RAILS_ENV" => "production" ),
          "max-load-per-proc" => 25,
          "min-procs" => 1,
          "max-procs" => 1,
          "idle-timeout" => 60
        )
    )
  ) 
}

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed