raksmart活动促销

分享

写回答

发帖

domain.com重新定向www.domain.com

国外VPS云主机 国外VPS云主机 1171 人阅读 | 2 人回复

发表于 2009-9-9 15:49:13 | 显示全部楼层 |阅读模式

惠普服务器
debain+lighttpd+php+mysql
  1. # Debian lighttpd configuration file
  2. #

  3. ############ Options you really have to take care of ####################

  4. ## modules to load
  5. # mod_access, mod_accesslog and mod_alias are loaded by default
  6. # all other module should only be loaded if neccesary
  7. # - saves some time
  8. # - saves memory

  9. server.modules              = (
  10.             "mod_fastcgi",
  11.             "mod_access",
  12.             "mod_alias",
  13.             "mod_accesslog",
  14.             "mod_compress",
  15.             "mod_rewrite",
  16. #           "mod_redirect",
  17.             "mod_evhost",
  18. #           "mod_usertrack",
  19. #           "mod_rrdtool",
  20. #           "mod_webdav",
  21. #           "mod_expire",
  22. #           "mod_flv_streaming",
  23. #           "mod_evasive"
  24. )

  25. ## a static document-root, for virtual-hosting take look at the
  26. ## server.virtual-* options
  27. server.document-root       = "/var/www/"

  28. ## where to upload files to, purged daily.
  29. server.upload-dirs = ( "/var/cache/lighttpd/uploads" )

  30. ## where to send error-messages to
  31. server.errorlog            = "/var/log/lighttpd/error.log"

  32. ## files to check for if .../ is requested
  33. index-file.names           = ( "index.php", "index.html",
  34.                                "index.htm", "default.htm",
  35.                                "index.lighttpd.html" )


  36. ## Use the "Content-Type" extended attribute to obtain mime type if possible
  37. # mimetype.use-xattr = "enable"

  38. #### accesslog module
  39. accesslog.filename         = "/var/log/lighttpd/access.log"

  40. ## deny access the file-extensions
  41. #
  42. # ~    is for backupfiles from vi, emacs, joe, ...
  43. # .inc is often used for code includes which should in general not be part
  44. #      of the document-root
  45. url.access-deny            = ( "~", ".inc",".log" )

  46. ##
  47. # which extensions should not be handle via static-file transfer
  48. #
  49. # .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
  50. static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )


  51. ######### Options that are good to be but not neccesary to be changed #######

  52. ## Use ipv6 only if available.
  53. include_shell "/usr/share/lighttpd/use-ipv6.pl"

  54. ## bind to port (default: 80)
  55. # server.port               = 81

  56. ## bind to localhost only (default: all interfaces)
  57. ## server.bind                = "localhost"

  58. ## error-handler for status 404
  59. #server.error-handler-404  = "/error-handler.html"
  60. #server.error-handler-404  = "/error-handler.php"

  61. ## to help the rc.scripts
  62. server.pid-file            = "/var/run/lighttpd.pid"

  63. ##
  64. ## Format: <errorfile-prefix><status>.html
  65. ## -> ..../status-404.html for 'File not found'
  66. #server.errorfile-prefix    = "/var/www/"

  67. ## virtual directory listings
  68. dir-listing.encoding        = "utf-8"
  69. server.dir-listing          = "enable"

  70. ## send unhandled HTTP-header headers to error-log
  71. #debug.dump-unknown-headers  = "enable"

  72. ### only root can use these options
  73. #
  74. # chroot() to directory (default: no chroot() )
  75. #server.chroot            = "/"

  76. ## change uid to <uid> (default: don't care)
  77. server.username            = "www-data"

  78. ## change uid to <uid> (default: don't care)
  79. server.groupname           = "www-data"

  80. #### compress module
  81. compress.cache-dir          = "/var/cache/lighttpd/compress/"
  82. compress.filetype           = ("text/plain", "text/html", "application/x-javascript", "text/css")


  83. #### url handling modules (rewrite, redirect, access)
  84. # url.rewrite                 = ( "^/$"             => "/server-status" )
  85. # url.redirect                = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )

  86. #
  87. # define a pattern for the host url finding
  88. # %% => % sign
  89. # %0 => domain name + tld
  90. # %1 => tld
  91. # %2 => domain name without tld
  92. # %3 => subdomain 1 name
  93. # %4 => subdomain 2 name
  94. #
  95. # evhost.path-pattern = "/home/storage/dev/www/%3/htdocs/"

  96. #### expire module
  97. # expire.url                  = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")

  98. #### rrdtool
  99. # rrdtool.binary = "/usr/bin/rrdtool"
  100. # rrdtool.db-name = "/var/www/lighttpd.rrd"

  101. #### variable usage:
  102. ## variable name without "." is auto prefixed by "var." and becomes "var.bar"
  103. #bar = 1
  104. #var.mystring = "foo"

  105. ## integer add
  106. #bar += 1
  107. ## string concat, with integer cast as string, result: "www.foo1.com"
  108. #server.name = "www." + mystring + var.bar + ".com"
  109. ## array merge
  110. #index-file.names = (foo + ".php") + index-file.names
  111. #index-file.names += (foo + ".php")


  112. #### external configuration files
  113. ## mimetype mapping
  114. include_shell "/usr/share/lighttpd/create-mime.assign.pl"

  115. ## load enabled configuration files,
  116. ## read /etc/lighttpd/conf-available/README first
  117. include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

  118. #### handle Debian Policy Manual, Section 11.5. urls
  119. ## by default allow them only from localhost
  120. ## (This must come last due to #445459)
  121. ## Note: =~ "127.0.0.1" works with ipv6 enabled, whereas == "127.0.0.1" doesn't
  122. $HTTP["remoteip"] =~ "127.0.0.1" {
  123.         alias.url += (
  124.                 "/doc/" => "/usr/share/doc/",
  125.                 "/images/" => "/usr/share/images/"
  126.         )
  127.         $HTTP["url"] =~ "^/doc/|^/images/" {
  128.                 dir-listing.activate = "enable"
  129.         }
  130. }
  131. fastcgi.server = (".php" => ((
  132. "bin-path" => "/usr/bin/php5-cgi",
  133. "socket" => "/tmp/php.socket"
  134. )))

  135. $HTTP["host"] == "www.youling.biz" {
  136. server.name = "youling.biz"
  137.   server.document-root = "/home/youling/webroot"
  138.   server.errorlog = "/home/youling/webroot/error.log"
  139.   accesslog.filename = "/home/youling/webroot/access.log"
  140. }
  141. $HTTP["host"] == "^youling\.biz$" {   
  142.   url.redirect = ( "^/(.*)" => "http://www.youling.biz/$1" )   
  143. }  
复制代码

回答|共 2 个

gg82805253

发表于 2009-9-9 16:11:49 | 显示全部楼层

$HTTP["host"] == "^youling\.biz$" {   
  url.redirect = ( "^/(.*)" => "http://www.youling.biz/$1" )   
}  
我已经这样设置了,还是不行阿

gg82805253

发表于 2009-9-9 16:58:57 | 显示全部楼层

已经自己解决,改成$HTTP["host"] =~ "^youling\.biz$" {   即可
您需要登录后才可以回帖 登录 | 注册

本版积分规则