Gallery:Lighttpd URL重写

来自站长百科
Sunzz1985讨论 | 贡献2008年6月10日 (二) 14:01的版本 (新页面: ==Introduction== The URL Rewrite module does not directly support [http://lighttpd.net/ lighttpd], but can be made to work by manually putting rewrite rules i...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Introduction

The URL Rewrite module does not directly support lighttpd, but can be made to work by manually putting rewrite rules in place.

Instructions

  1. Get a working gallery2 installation
  2. In the Plugins section of the Site Admin web interface, configure the URL Rewrite module so that it uses Apache mod_rewrite; you might need to force the bypass of the tests, and tell it that it works
  3. Create the (unnecesary) .htaccess file and give it read-write permissions. The commands should look something like this:
touch /srv/www/localhost/gallery2/.htaccess
chmod 666 /srv/www/localhost/gallery2/.htaccess
  1. Complete activation of URL Rewrite module; if you want, you can remove all the contents of the .htaccess file created by gallery2
  2. Activate the Permalinks module if desired
  3. Edit as root your Lighty's configuration file, which may be at /etc/lighttpd/lighttpd.conf and uncomment (remove the #) of the line in which you can read mod_rewrite. If you cannot find this line, just add "mod_rewrite",' to the server.modules section. For example, mine looks like this:
server.modules              = (
                               "mod_rewrite",
                               "mod_access",
                               "mod_fastcgi",
                               "mod_ssi",
                               "mod_usertrack",
                               "mod_accesslog" )

Your Lighty will load that module. Now you have to add the url.rewrite rules to your configuration file. Lighty will parse the requested url and go transparently to the destination defined after the '=>'. Add these lines to your /etc/lighttpd/lighttpd.conf file:

url.rewrite = (
 "^/(.*)/Rewrite.txt$" => "/$1/Works.txt",
 "^/gallery2/v/(\?.+|\ .)?$" => "/gallery2/main.php?g2_view=core.ShowItem",
 "^/gallery2/admin[/?]*(.*)$" => "/gallery2/main.php?g2_view=core.SiteAdmin&$1",
 "^/gallery2/d/([0-9]+)-([0-9]+)/([^\/]+)(\?|\ )?(.*)$" =>
 "/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=$1&g2_serialNumber=$2&$3",
 "^/gallery2/v/([^?]+)/slideshow.html" =>
 "/gallery2/main.php?g2_view=slideshow.Slideshow&g2_path=$1",
 "^/gallery2/v/([^?]+)(\?|\ )?(.*)$" =>
 "/gallery2/main.php?g2_view=core.ShowItem&g2_path=$1&$3",
 "^/gallery2/c/add/([0-9]+).html" =>
 "/gallery2/main.php?g2_view=comment.AddComment&g2_itemId=$1",
 "^/gallery2/c/view/([0-9]+).html" =>
 "/gallery2/main.php?g2_view=comment.ShowAllComments&g2_itemId=$1",
 "^/gallery2/p/(.+)" =>
 "/gallery2/main.php?g2_controller=permalinks.Redirect&g2_filename=$1",
 "^/key/([^?]+)(\?|\ )?(.*)$" =>
 "/main.php?g2_view=keyalbum.KeywordAlbum&g2_keyword=$1&$3"
 )

If needed, change gallery2 to your gallery2 path. The above rules are for the default patterns in the URL Rewrite module (the /v/, /d/, etc parts above). Any changes to these in URL Rewrite Site Admin will require matching changes to these rules.

Stop Lighty, and start it again from a commandline to see if you have made any typo. If it gives no error, it should be working.

Links