如果我沒有域名,如何設定乾淨的網址(啟用重寫)?

如果我沒有域名,如何設定乾淨的網址(啟用重寫)?

為了在 Drupal 中啟用乾淨的 url,我將以下行新增到lighttpd 設定檔中。

但是我現在正在本地伺服器上工作,並且沒有可用的網域。所以我需要使用這個位址 192.168.75.159:81/Sites/drupal/

我嘗試用​​ ["socket"] 替換 ["host"] 並用 ip 和子資料夾替換網域(請參閱上面的位址),但沒有成功。即使我沒有域名,如何設定設定檔來設定乾淨的網址?

謝謝

$HTTP["host"] =~ "(^|\.)mywebsite\.com" {
  server.document-root = "/var/www/sites/mywebsite"
  server.errorlog = "/var/log/lighttpd/mywebsite/error.log"
  server.name = "mywebsite.com"
  accesslog.filename = "/var/log/lighttpd/mywebsite/access.log"
  include_shell "./drupal-lua-conf.sh mywebsite.com"

  url.access-deny += ( "~", ".inc", ".engine", ".install", ".info",
       ".module", ".sh", "sql", ".theme",
       ".tpl.php", ".xtmpl", "Entries",
       "Repository", "Root" )


  # "Fix" for Drupal SA-2006-006, requires lighttpd 1.4.13 or above
  # Only serve .php files of the drupal base directory
  $HTTP["url"] =~ "^/.*/.*\.php$" {
      fastcgi.server = ()
      url.access-deny = ("")
  }

  magnet.attract-physical-path-to = ("/etc/lighttpd/drupal-lua-scripts/p-.lua")

}

答案1

我不知道您使用的是什麼作業系統,但您可以在*nix 系統上的/etc/hosts 和c:\Windows\System32\Drivers\etc\hosts 中新增一行,以允許您對應mywebsite.com (或dev.com)。

或者更好的想法是,如果您控制 DNS,只需建立子網域 A 記錄(例如 dev.mywebsite.com)並將其指向 127.0.0.1。

相關內容