dtmwnqng38644
2017-03-23 09:48
浏览 298
已采纳

如何将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?

图片转代码服务由CSDN问答提供 功能建议

这是我的nginx.conf内容:

  if(  !-e $ request_filename){
 
 rewrite ^ /(.*)/index.php/$1 last; 
 
 break; 
} 
 
 rewrite_log on; 
 
 location~。*  \ .svn \ /。* {return 405;  } 
 
位置〜。* \ .php {
 fastcgi_pass 127.0.0.1:9000; 
包括fastcgi.conf; 
} 
 
位置〜* \。(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] 
   
 
 

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

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqrnsg6439 2017-03-23 09:58
    已采纳

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

    not

     RewriteRule ^(.*)$ /index.php/$1 [L]
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题