nginx localtion中想匹配 /index.html?page= 开头,或者匹配所有带有 ?的url,跳转到动态请求,

Jlins 2014-10-27 03:58:29
nginx localtion中想匹配 /index.html?page= 开头,或者匹配所有带有 ?的url,跳转到动态请求,

location 这里如何写?
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://tomcat;
}
...全文
837 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jlins 2014-11-04
  • 打赏
  • 举报
回复
发错了///.........
Jlins 2014-10-27
  • 打赏
  • 举报
回复
引用 3 楼 qyj415 的回复:
location ~*html\?page { }
貌似不行, #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; gzip_comp_level 4; gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg imag e/gif image/png; upstream tomcat{ server localhost:8080; } server { listen 80; server_name localhost; charset utf-8; #access_log logs/host.access.log main; #all not /html/ request with pass form it as /js/ /css// location / { root /root/aliyun/html; index index.html index.htm; } location ^~ /html/kindeditor/pic/ { root /root/aliyun; expires 30d; } location ^~ /html/images/ { root /root/aliyun; expires 30d; } location ~ .*\.(html|htm)$ { root /root/aliyun/html; index index.html index.htm; } location ~*html\?page { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://tomcat; } location ^~ /site/images/ { root /home/jlins/apache-tomcat-6.0.41/webapps/ROOT; expires 30d; } location ~ .*\.(js|css)?$ { root /home/jlins/apache-tomcat-6.0.41/webapps/ROOT; expires 24h; } location ^~ /html/ { root /root/aliyun; expires 1h; } location ^~ /channel/ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://tomcat; } location ~ .*\.(php|jsp|cgi|do|action)?$ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://tomcat; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
独行码夫 2014-10-27
  • 打赏
  • 举报
回复
location ~*html\?page { }
独行码夫 2014-10-27
  • 打赏
  • 举报
回复
location ~html* \?page { } 这样行不行~
Jlins 2014-10-27
  • 打赏
  • 举报
回复
求个匹配正则串 自己试验了好多都不行

25,985

社区成员

发帖
与我相关
我的任务
社区描述
高性能WEB开发
社区管理员
  • 高性能WEB开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧