大家都知道Drupal在apache环境下使用简洁链接是件很轻松的事,因为官方已经把写好的.htaccess文件附在源代码里,一般在配置里直接就可以打开了。但在Nginx下却没有那么简单,但不用担心,实事上并不怎么复杂。简单来说,其实就是添加一段很短的代码就可以了,你也没必要理解原理。
在你的nginx配置文件下添加(红色部分):
server { listen 80; server_name mentry.cn; #server_name end index index.html index.htm index.php; #index end root /home/wwwroot/mentry.cn/web$subdomain; location / { try_files $uri $uri/ /index.php; } }
假如我的网站使用了虚拟主机技术,那么只需要虚拟主机配置文件中直接添加就可以了。例如我的是使用AMH4.0套件(LNMP),那么在/usr/local/nginx/conf/vhost/下有类似“mentry.net.conf”虚拟主机配置文件,打开后,添加红色代码就可以了。
server
{
listen
80;
server_name mentry.net; #server_name
end
index index.html index.htm index.php; #index end
set $subdomain ‘‘;
root
/home/wwwroot/mentry.net/web$subdomain;
include
rewrite/amh.conf; #rewrite end
#error_page
error_page 400
/ErrorPages/400.html;
error_page 403
/ErrorPages/403.html;
error_page 404
/ErrorPages/404.html;
error_page 502
/ErrorPages/502.html;
location ~
/ErrorPages/(400|401|403|404|405|502|503)\.html$
{
root
/home/wwwroot/mentry.cn/web;
}
location ~ .*\.php$
{
fastcgi_pass
unix:/tmp/php-cgi-mentry.cn.sock;
fastcgi_index index.php;
include
fcgi-host.conf;
fastcgi_param
DOCUMENT_ROOT /web$subdomain;
fastcgi_param SCRIPT_FILENAME
/web$subdomain$fastcgi_script_name;
}
location ~
.*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
{
expires
30d;
}
location ~ .*\.(js|css)$
{
expires
12h;
}
access_log off; #access_log end
error_log /dev/null; #error_log end
location / {
try_files $uri $uri/ /index.php;
}
}
Nginx下轻松开启Drupal简洁链接,布布扣,bubuko.com
原文:http://www.cnblogs.com/suihui/p/3603334.html