如何将Nginx重写规则更改为Apache?

时间:2017-03-23 09:48:00

标签: php apache .htaccess nginx

这是我的nginx.conf内容:

if (!-e $request_filename) {

            rewrite ^/(.*) /index.php/$1 last;

            break;
    }

    rewrite_log on;

    location ~ .*\.svn\/.* { return 405; }

    location ~ .*\.php {
            fastcgi_pass  127.0.0.1:9000;
            include fastcgi.conf;
    }

    location ~* \.(html|shtml|htm|inc|log)$ {
            expires 1m;
    }
    location ~* \.(css|js)$ {
            expires 1m;
    }
    location ~* ^.+\.(jpg|jpeg|gif|swf|mpeg|mpg|mov|flv|asf|wmv|avi|ico)$ {
            expires 15d;
    }

我将其中一些更改为Apache,如下所示:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]

但是当我隐藏在url中的/index.php/时,我无法加载我的静态资源(css,js,img.etc),如何将nginx location规则更改为Apache?

1 个答案:

答案 0 :(得分:0)

应该是  RewriteRule ^(.*)$ /index.php?/$1 [L] ?

<强>不

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