2014-08-27 2 views
0

내가 원하는 리디렉션되지 않습니다 PNG의 URL의 지금 정중하게의 nginx : 홈페이지의이

http://www.imvuoutfits.com/submit/images/declined.png http://www.imvuoutfits.com/submit/images/approved.png

를 가리 키도록

http://www.imvuoutfits.com/hpv/images/declined.png http://www.imvuoutfits.com/hpv/images/approved.png

. 나는 사용하여 시도했다 :

location ~ /hpv/images { 
     rewrite /hpv/images/declined.png http://www.imvuoutfits.com/submit/images/declined.png redirect; 
     rewrite /hpv/images/approved.png http://www.imvuoutfits.com/submit/images/approved.png redirect; 
    } 

을 나는 또한 시도했다 :

location /hpv/images/declined\.png { 
    rewrite ^/(.+) "http://www.imvuoutfits.com/submit/images/declined.png" redirect; 
} 

location /hpv/images/approved\.png { 
    rewrite ^/(.+) "http://www.imvuoutfits.com/submit/images/approved.png" redirect; 
} 

하지만 어느 작품, 그것은 충돌이있을 수 있습니다 - 내가, 내 모든 conf의 파일이 아닌 확신 :

server { 
    server_name imvuoutfits.com; 
    return  301 http://www.imvuoutfits.com$request_uri; 
} 

server { 
    root /var/www/sedulity; 
    index index.php index.html index.htm; 

    server_name www.imvuoutfits.com *.imvuoutfits.com; 



    access_log /var/log/nginx/sedulity_access.log; 
    #rewrite_log on; 
    error_log /var/log/nginx/sedulity_error.log; 
    #error_log /var/log/nginx/imvu_error.log notice; 
    #error_log /var/log/nginx/imvu_error.log info; 



    rewrite /wp-admin$ $scheme://$host$uri/ permanent; 



    location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico|txt|xml|bmp|pdf|doc|docx|ppt|pptx|zip)$ { 
     access_log off; 
     expires 30d; 
    } 



    location/{ 
     try_files $uri $uri/ /index.php?$args; 
     expires 30d; ## Assume all files are cachable 
     if ($request_uri ~* "\.(png|gif|jpg|jpeg|css|js|swf|ico|txt|xml|bmp|pdf|doc|docx|ppt|pptx|zip)$") { 
      expires max; 
     } 
    } 

    location /submit/try { 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME /var/www/sedulity/submit/try.php; 
    } 

    location /submit/outfit { 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME /var/www/sedulity/submit/outfit.php; 
    } 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     if (!-f $document_root$fastcgi_script_name) { 
      return 404; 
     } 

     proxy_read_timeout 600; 
     fastcgi_read_timeout 600; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
     ##################### 
     fastcgi_param imvu_user livindeadgirlx; 
     fastcgi_param imvu_pass Xhfd83rh; 
     ##################### 
     fastcgi_param db_host daldb.vpsdime.com; 
     fastcgi_param db_user xoxo; 
     fastcgi_param db_pass lmiNumkw2nje3; 

     fastcgi_param REDIRECT_URL $request_uri; #This solve all my problems :D. 
    } 

    # deny access to .htaccess files, if Apache's document root 
    location ~ /\.ht { 
     deny all; 
    } 

    ########################################## 

    # Allow access to /wp-admin/ only to a specific IP address 
    location ~* wp-admin { 
     try_files $uri $uri/ =404; 
     allow 127.0.0.1; 
     deny all; 
    } 

    # http://blog.bigdinosaur.org/wordpress-on-nginx/ 
    # Common deny or internal locations, to help prevent access to not-public areas 
    location ~* wp-admin/includes { deny all; } 
    location ~* wp-includes/theme-compat/ { deny all; } 
    location ~* wp-includes/js/tinymce/langs/.*\.php { deny all; } 
    location /wp-content/ { internal; } 
    location /wp-includes/ { internal; } 
    location ~* wp-config.php { deny all; } 

    # Prevent any potentially-executable files in the uploads directory from being executed 
    # by forcing their MIME type to text/plain 
    location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php|js|swf)$ { 
     types { } 
     default_type text/plain; 
    } 

    # Rewrite rules for Wordpress SEO by Yoast 
    rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last; 
    rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; 

    # Add trailing slash to */wp-admin requests 
    rewrite /wp-admin$ $scheme://$host$uri/ permanent; 

    # Redirect 403 errors to 404 error to fool attackers 
    error_page 403 = 404; 

    ########################################## 

    location ~ /hpv/images { 
     rewrite /hpv/images/declined.png http://www.imvuoutfits.com/submit/images/declined.png redirect; 
     rewrite /hpv/images/approved.png http://www.imvuoutfits.com/submit/images/approved.png redirect; 
    } 

    if ($request_uri ~ "^/hpv/upload/server/php/files/(.*)$"){ 
     rewrite ^/(.+) "http://media.imvuoutfits.com/screenshots/%1" break; 
    } 



    # BEGIN W3TC Minify core 
    rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 last; 
    rewrite ^/wp-content/cache/minify/(.+/[X]+\.css)$ /wp-content/plugins/w3-total-cache/pub/minify.php?test_file=$1 last; 
    rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1 last; 
    # END W3TC Minify core 

    # BEGIN W3TC Browser Cache 
    gzip on; 
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; 
    # END W3TC Browser Cache 

    # BEGIN W3TC CDN 
    location ~ \.(ttf|ttc|otf|eot|woff|font.css)$ { 
     add_header Access-Control-Allow-Origin "*"; 
    } 
    # END W3TC CDN 

} 
+0

'위치 ~ * \. (png | gif | ...'는 요청 및 검색 이미지와 일치합니다. –

+0

괜찮 았던 것 같습니다. 경기가 계속 진행되고 다른 경기를하려고하는 인상을 받고 있었지만, 중첩 된 위치가 필요합니다. 답변을 작성하여 표시하도록하겠습니다. – ParoX

답변

1

Nginx location은 독점적입니다.

따라서 location ~* \.(png|gif|...에 들어가서 추가 한 새 위치에 절대 도착하지 마십시오. 중첩 된 위치로 지정하십시오.