Redirect nginx重定向不';行不通
我需要实现的是重定向Redirect nginx重定向不';行不通,redirect,nginx,Redirect,Nginx,我需要实现的是重定向http://domain.com/PS160/img/p/9/9/1/7/9/99179.jpg至http://domain.com/img/p/9/9/1/7/9/99179.jpg 它所做的是重定向http://domain.com/PS160/img/p/9/9/1/7/9/img//PS160/img/p/9/9/1/7/9/img//PS160/img/p/9/9/1/7/9/img/PS160/img/p/9/9/1/7/9/img//PS160/img/p/9
http://domain.com/PS160/img/p/9/9/1/7/9/99179.jpg
至http://domain.com/img/p/9/9/1/7/9/99179.jpg
它所做的是重定向http://domain.com/PS160/img/p/9/9/1/7/9/img//PS160/img/p/9/9/1/7/9/img//PS160/img/p/9/9/1/7/9/img/PS160/img/p/9/9/1/7/9/img//PS160/img/p/9/9/1/7/9/img/...
-414请求URI太大
文件名中还有一些特定的单词:
location / {rewrite ^/PS160/img/(.*)\.jpg$ /img/$1 permanent;}
它不起任何作用:
http://www.domain.com/59229-thickbox/tommy-hilfiger-planbok.jpg
->http://www.domain.com/59229/tommy-hilfiger-planbok.jpg
http://www.domain.com/img/p/6/2/4/7/4/62474-thickbox.jpg
->
http://www.domain.com/img/p/6/2/4/7/4/62474.jpg
正确的做法是什么
编辑:nginx congig文件:/etc/nginx/sites available/nord-presta.ddns.me.vhost:
location /img { rewrite ^/(.*)-thickbox\.(png|jpg)$ /$1.$2 redirect; }
显示完整的nginx配置。另外,您的第一次重写丢失文件扩展是否需要扩展?我必须从url中删除-thickbox,不管它是什么文件。它有两种方式,一种是重写url,另一种是物理url。
server {
listen *:80;
server_name nord-presta.ddns.me www.nord-presta.ddns.me www.nordbags.com nordbags.com www.nordwatches.com nordwatches.com www.nord-presta-watch.ddns.net nord-presta-watch.ddns.net www.nordoutlet.com nordoutlet.com;
root /var/www/nord-presta.ddns.me/web;
if ($http_host = "nordbags.com") {
rewrite ^ $scheme://www.nordbags.com$request_uri? permanent;
}
if ($http_host = "nordwatches.com") {
rewrite ^ $scheme://www.nordwatches.com$request_uri? permanent;
}
if ($http_host = "nordoutlet.com") {
rewrite ^ $scheme://www.nordoutlet.com$request_uri? permanent;
}
location /nordbags.com/ {
rewrite ^nordbags.com/(.*)$ /$1 last;
try_files $uri $uri/ /index.php?$args;
}
location /nordwatches.com/ {
rewrite ^nordwatches.com/(.*)$ /$1 last;
try_files $uri $uri/ /index.php?$args;
}
# location /nordoutlet.com/ {
# rewrite ^nordoutlet.com/(.*)$ /$1 last;
# try_files $uri $uri/ /index.php?$args;
# }
index index.html index.htm index.php index.cgi index.pl index.xhtml;
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg last;
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 last;
try_files $uri $uri/ /index.php$is_args$args;
error_page 404 /index.php?controller=404;
error_log /var/log/ispconfig/httpd/nord-presta.ddns.me/error.log;
access_log /var/log/ispconfig/httpd/nord-presta.ddns.me/access.log combined;
location /stats {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client0/web1/web/stats/.htpasswd_stats;
}
location ^~ /awstats-icon {
alias /usr/share/awstats/icon;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
}
# location /img { rewrite ^/(.*)-thickbox\.(png|jpg)$ /$1.$2 redirect; }
location / { rewrite ^/(.*)-thickbox\.(.*)$ /$1-large\.(.*) redirect; }
location ~* \.(gif)$ {
expires 2592000s;
}
location ~* \.(jpeg|jpg)$ {
expires 2592000s;
}
location ~* \.(png)$ {
expires 2592000s;
}
location ~* \.(css)$ {
expires 604800s;
}
location ~* \.(js|jsonp)$ {
expires 604800s;
}
location ~* \.(js)$ {
expires 604800s;
}
location ~* \.(ico)$ {
expires 31536000s;
}
}