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!)

« 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

DiG for gtcaz3

dig @dns1.textdrive.com alexandracheshire.com

; <<>> DiG 9.3.1 <<>> @dns1.textdrive.com alexandracheshire.com
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10904
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;alexandracheshire.com. IN A

;; ANSWER SECTION:
alexandracheshire.com. 2400 IN A 207.7.108.242

;; Query time: 33 msec
;; SERVER: 67.19.231.130#53(67.19.231.130)
;; WHEN: Wed Sep 7 19:59:38 2005
;; MSG SIZE rcvd: 55

DiG for Simplicio.com

dig @dns1.textdrive.com simplicio.com

; <<>> DiG 9.3.1 <<>> @dns1.textdrive.com simplicio.com
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45365
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;simplicio.com. IN A

;; ANSWER SECTION:
simplicio.com. 1200 IN A 207.7.108.101

;; Query time: 40 msec
;; SERVER: 67.19.231.130#53(67.19.231.130)
;; WHEN: Wed Sep 7 19:37:33 2005
;; MSG SIZE rcvd: 47
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed