我自己创建的虚拟机不能用
server {
listen 80;
server_name evathumber.avnpc.com;
location / {
root /usr/www/EvaThumber/;
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php last;
}
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/www/EvaThumber/$fastcgi_script_name;
}
}
5 Answers
@oneinstack
我把项目里边的 .htaccess内容改写成nginx之后还是不能访问,我哪个地方写错了吗? url重写还是不生效
我把项目里边的 .htaccess内容改写成nginx之后还是不能访问,我哪个地方写错了吗? url重写还是不生效
server {
listen 80;
server_name img.zoo521.com;
access_log /data/wwwlogs/img.zoo521.com_nginx.log combined;
index index.html index.htm index.php;
#include /usr/local/nginx/conf/rewrite/img.zoo521.conf;
root /data/wwwroot/img.zoo521.com;
location / {
if (!-e $reauest_filename) {
rewrite ^/(.*)$ /index.php last;
break;
}
}
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
}
# ----------------------------------------------------------------------
# CORS-enabled images (@crossorigin)
# ----------------------------------------------------------------------
# Send CORS headers if browsers request them; enabled by default for images.
# developer.mozilla.org/en/CORS_Enabled_Image
# blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
# hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
# wiki.mozilla.org/Security/Reviews/crossoriginAttribute
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
# mod_headers, y u no match by Content-Type?!
<FilesMatch "\.(gif|ico|jpe?g|png|svg|svgz|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
# FileETag None is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
# Since we're sending far-future expires, we don't need ETags for
# static content.
# developer.yahoo.com/performance/rules.html#etags
FileETag None
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
Please login or Register to submit your answer