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

如何将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 2017-03-23 09:58
    关注

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

    not

     RewriteRule ^(.*)$ /index.php/$1 [L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到