用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4414|回复: 5
收起左侧

[已解决] 在nginx如何隐藏index.php?

[复制链接]
发表于 2012-2-17 01:22:50 | 显示全部楼层 |阅读模式
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [PT,L]

以上的是在本地apache上的,没问题,但是传到nginx上就不行了。请问apache是否和xginx的rewrite不同呢?

 楼主| 发表于 2012-2-17 01:39:53 | 显示全部楼层
而且,即使加上index.php。也不正常。。。。

如下图:
本地的:
bendi.jpg
本地加上index.php
bendi2.jpg

服务器上的:
nginx.jpg
发表于 2012-2-17 10:22:01 | 显示全部楼层
server
        {
                listen       80;
                server_name 网站域名;
                index index.html index.htm index.php;
                root  /usr/local/web/pr/;
                location / {
                        if (!-e $request_filename) {
                                rewrite ^/(.*)$ /index.php/$1 last;
                        }
                }
               
                if ($request_filename !~* /(js|skin|upload|style|ls|img|css|images|fckeditor|userfiles|crontab|robots\.txt|index\.php|system\.php)) {
                        rewrite ^/(.*)$ /index.php?$1 last;
                }
                if ($request_filename ~* /(system\.php)) {
                        rewrite ^/(.*)$ /system.php?$1 last;
                }
                if ($request_filename ~* /(system\.php)) {
                        rewrite ^/(.*)$ /webscan_360_cn.html?$1 last;
                }
                location ~ \.php {
                        set $real_script_name $fastcgi_script_name;
                        set $path_info "";
                        if ($fastcgi_script_name ~ "^(.+?//.php)(/.+)$") {  
                                set $real_script_name $1;   
                                set $path_info $2;   
                }   
            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;
                        fastcgi_pass  unix:/tmp/php-cgi.sock;
                        fastcgi_index index.php;
            include fcgi.conf;
               
                }
                 
                location /status {
                        stub_status on;
                        access_log   off;
                }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }
        }
 楼主| 发表于 2012-2-17 10:39:49 | 显示全部楼层
这么长的一段。。。。写在哪里的?
写在.htaccess文件上吗?
发表于 2012-2-17 12:36:21 | 显示全部楼层
vergil 发表于 2012-2-17 10:39
这么长的一段。。。。写在哪里的?
写在.htaccess文件上吗?

nginx 没有 .htaccess
你可以在论坛搜索 nginx,或者用CI搜索引擎搜索。
 楼主| 发表于 2012-2-17 13:33:23 | 显示全部楼层
那加上index。php也不正常是在怎么回事?

本版积分规则