dtmwnqng38644
dtmwnqng38644
2017-03-23 09:48

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

Here is my nginx.conf content:

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;
    }

I changed some of this to Apache like this:

RewriteEngine on

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

But when I hided the /index.php/ in url, I can't load my static resources( css,js,img.etc),how can I change nginx location rule to Apache's?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dqrnsg6439 dqrnsg6439 4年前

    It should be RewriteRule ^(.*)$ /index.php?/$1 [L] with ?

    not

     RewriteRule ^(.*)$ /index.php/$1 [L]
    
    点赞 评论 复制链接分享