我正在努力通过以下设置为prestashop设置重写规则
> Prestashop 1.6
> SSL
>多语言网站(在我的案例中)
> Nginx 1.4.1(这对我发现的ssl设置很重要)
我使用了下面的一些参考资料
http://www.prestashop.com/forums/topic/323391-another-nginx-ssl-rewrite-rules-problem/
http://www.prestashop.com/forums/topic/321261-seo-friendly-nginx-rewrites/(不是多语言)
PRESTASHOP NGINX + REWRITE RULES
并在下面得到这个配置.
一切都有效,除了我的一些支付模块,它们会返回一个网址
mysite.com/en/index.PHP?parameter1=1\u0026amp;parameter2=2
这会触发404
它看起来应该被重写为url
mysite.com/index.PHP?parameter1=1\u0026amp;parameter2=2
我有两个问题:
>哪个规则正在处理像mysite.com/en/16-crews这样工作正常的网址?
它翻译成了什么? (我很想知道它是如何工作的)
>如何设置重写规则
mysite.com/en/index.PHP?parameter1=1\u0026amp;parameter2=2
至
mysite.com/index.PHP?parameter1=1\u0026amp;parameter2=2
它还必须与站点/fr/index.PHP的法语方面一起使用到/index.PHP
server {
listen 80;
listen 443 ssl;
server_name mysite.com www.mysite.com;
ssl on;
ssl_certificate /etc/Nginx/ssl/mysite.crt;
ssl_certificate_key /etc/Nginx/ssl/mysite.key;
access_log /var/log/Nginx/mysite.access.log;
error_log /var/log/Nginx/mysite.error.log;
rewrite_log on;
location / {
root /srv/d_h2osensations/www/www.mysite.com/htdocs;
index index.html index.htm index.PHP;
rewrite ^/api/?(.*)$/webservice/dispatcher.PHP?url=$1 last;
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$/img/p/$1/$1$2.jpg last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$/img/p/$1/$2/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$/img/p/$1/$2/$3/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$- img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$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])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$/img/c/$1$2.jpg last;
rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$/img/c/$1.jpg last;
rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$/img/c/$1$2.jpg last;
try_files $uri $uri/ /index.PHP?$args;
}
location ~ \.PHP${
fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
fastcgi_pass unix:/var/run/PHP5-fpm.sock;
fastcgi_index index.PHP;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /srv/d_h2osensations/www/www.mysite.com/htdocs$fastcgi_script_name;
}
# Deny access to .htaccess
location ~ /\.ht {
deny all;
}
location /PHPmyadmin
{ root /usr/share/;
index index.PHP index.html index.htm;
location ~ ^/PHPmyadmin/(.+\.PHP)${
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/PHP5-fpm.sock;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/PHPmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))${
root /usr/share/;
}
}
location /PHPMyAdmin {
rewrite ^/* /PHPmyadmin last;
}
}
提前致谢.
尼克
解决方法:
经过几周的环顾四周,这对我有用
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
listen 443 default ssl;
#ssl on;
ssl_certificate /etc/Nginx/ssl/cert.crt;
ssl_certificate_key /etc/Nginx/ssl/cert-key.key;
access_log /var/log/Nginx/h2o.prod.access.log;
error_log /var/log/Nginx/h2o.prod.error.log;
root /var/www/www.mysite.com/htdocs;
#root /usr/share/Nginx/html;
index index.html index.htm index.PHP;
# Make site accessible from http://localhost/
server_name mysite.com www.mysite.com;
#Specify a charset
charset utf-8;
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-]*)/[_a-zA-Z0-9-]*.jpg$/img/c/$1$2.jpg last;
rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$/img/c/$1.jpg last;
rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$/img/c/$1$2.jpg last;
rewrite ^/order$/index.PHP?controller=order last;
if (!-e $request_filename){
rewrite ^(.*)$/index.PHP last;
}
# Redirect needed to "hide" index.PHP
location / {
try_files $uri $uri/ /index.PHP?q=$uri&$args;
}
location ~ \.PHP${
fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
fastcgi_pass unix:/var/run/PHP5-fpm.sock;
fastcgi_index index.PHP;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with Nginx's one
location ~ /\.ht {
deny all;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。