菜花大盗 大佬有话说 : 2020-3-19 16:30:37
又来请教.htaccess转nginx的问题了,依然急求在线等
htacces规则如下:
Options -Indexes +FollowSymLinks
AddDefaultCharset UTF-8
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}
#RewriteCond %{HTTP_HOST} !^www.
#RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI}
<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
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1
</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; 重复
淘宝找了两个都没搞定, 有没有大佬可以指点一二,付费是肯定的。
lowendtalk 大佬有话说 : 2020-3-19 16:31:48
去stackoverflow提问不好吗?
Mr. 大佬有话说 : 2020-3-19 16:32:15
太长了看不懂。。。这么复杂的 rewrite 为什么不在程序里做。。。
h20 大佬有话说 : 2020-3-19 16:33:05
分类lighttpd却问的是apache转nginx的问题:lol:lol
lanchenyuan 大佬有话说 : 2020-3-19 16:33:38
看不懂…