幻想曲 发表于 2012-1-12 11:16:14

Nginx下Urlrewrite的配置

之前在Apache下可以配成:
http://localhost/show/1
这样的链接,实际URL是:http://localhost/index.php?m=index&c=show&id=1
现在到nginx下之后,访问
http://localhost/show/1会提示404,不知道这个该怎么写?
apache下的.htaccess是这样写的:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1

怎么对应到Nginx中呢?

sdink 发表于 2012-1-12 11:54:16

网站找一个,可以把Apache的转成Nginx的,不过Nginx有些问题要写在config里

cpass 发表于 2012-3-13 11:43:51


rewrite "^/(?!index\.php|robots\.txt|images|js|stylesheets)(.*)$" /index.php/$1 last;
if (!-e $request_filename) {
    rewrite ^.*$ /index.php last;
}

写在 “location / {}” 段里。
不过问题没这么简单,还有path_info的问题,我到这里走不下去了。

页: [1]
查看完整版本: Nginx下Urlrewrite的配置