全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1698|回复: 4

[nginx] 又来请教.htaccess转nginx的问题了,依然急求在线等

[复制链接]
发表于 2020-3-19 16:30:37 | 显示全部楼层 |阅读模式
htacces规则如下:
Options -Indexes +FollowSymLinks
AddDefaultCharset UTF-8
RewriteEngine On
RewriteBase /

#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<IfModule pagespeed_module>

    ModPagespeed off

</IfModule>

# exclude any paths that are not codeigniter-app related
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/docs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
#PAGESPEED
<IfModule mod_expires.c>
  ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault                          "access plus 1 month"
# cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
  ExpiresByType text/cache-manifest       "access plus 0 seconds"

# your document html
  ExpiresByType text/html                 "access plus 0 seconds"

# data
  ExpiresByType text/xml                  "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"

# rss feed
  ExpiresByType application/rss+xml       "access plus 1 hour"

# favicon (cannot be renamed)
  ExpiresByType image/x-icon              "access plus 1 month"

# media: images, video, audio
  ExpiresByType image/gif                 "access plus 3 months"
  ExpiresByType image/png                 "access plus 3 months"
  ExpiresByType image/jpg                 "access plus 3 months"
  ExpiresByType image/jpeg                "access plus 3 months"
  ExpiresByType video/ogg                 "access plus 3 months"
  ExpiresByType audio/ogg                 "access plus 3 months"
  ExpiresByType video/mp4                 "access plus 3 months"
  ExpiresByType video/webm                "access plus 3 months"

# htc files  (css3pie)
  ExpiresByType text/x-component          "access plus 1 month"

# webfonts
  ExpiresByType font/truetype             "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

# css and javascript
  ExpiresByType text/css                  "access plus 2 months"
  ExpiresByType application/javascript    "access plus 2 months"
  ExpiresByType text/javascript           "access plus 2 months"
  <IfModule mod_headers.c>
    Header append Cache-Control "public, no-transform"
    Header set Connection keep-alive
  </IfModule>

</IfModule>
#END PAGESPEED

转为nginx规则后:
# nginx configuration by winginx.com

autoindex off;

charset utf-8;

location ~ /server-status {
}

location ~ /server-info {
}

location ~ /docs {
}

autoindex off;

location / {
  if (!-e $request_filename){
    rewrite ^(.*)$ /index.php/$1 break;
  }
  rewrite ^(.*)$ /index.php?/$1 break;
}

重启nginx后运行正常

今天蛋疼装了一下bbr,重启服务器之后nginx就挂了,查看日志提示第十六行,也就是autoindex off; 重复
淘宝找了两个都没搞定, 有没有大佬可以指点一二,付费是肯定的。
发表于 2020-3-19 16:31:48 | 显示全部楼层
去stackoverflow提问不好吗?
发表于 2020-3-19 16:32:15 | 显示全部楼层
太长了看不懂。。。这么复杂的 rewrite 为什么不在程序里做。。。
发表于 2020-3-19 16:33:05 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-19 08:18 , Processed in 0.058159 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表