用下面的方法挣扎一下。 为JS和CSS添加过期,加上其他静态文件很容易: # Directives to send expires headers. location ~* \.(?:css|js)$ { expires 28d; access_log off; add_header Cache-Control "public"; } 但是对于我喜欢的url,我不太清楚。 重写的URL如下所示: www.domain.tld/post-name 所以没有像.html或.php这样的扩展名,而主页只是一个/注意我的主页是静态的,没有最新的新闻/博客文章等,所以我也希望这个caching在浏览器中。 将过期添加到此位置块不会将浏览器caching添加到主页: location / { try_files $uri $uri/ /index.php?$args; expires 1d; } 在php文件位置添加过期(重写之前)也不起作用,Nginx似乎想要确切的请求的URI。 我已经看到了这个build议,但是对使用太多的if语句表示谨慎: location / { if (-f $request_filename) { expires 30d; break; } } 什么是最好的方法来确保这样一个简单的5页面网站获取所有的页面浏览器caching? 理想情况下不需要对url进行硬编码。 www.domain.tld / www.domain.tld / […]
我有一个Azure VM托pipe一个Web应用程序。 该应用程序将通过虚拟机的IP地址访问: http://191.238.112.62 我希望能够使用查询stringredirect到本地 IIS中完全不同的站点。 例如: http://191.238.112.62/?site=1 会redirect到 www.site1.com 我的结构IIS的方式可以看到如下: 每个站点在系统主机文件中都有一个条目。 127.0.0.1 wwww.site1.com 127.0.0.1 wwww.site2.com 127.0.0.1 wwww.site3.com 有可能有一个更好的办法来实现我在这里,所以任何指针将不胜感激。 谢谢。
我有一个工作在fastcgi config在nginx中。 现在我有很less的要求/X , /X /X.php处理/Y.php /Y听起来很简单,所以我写了下面的testing: rewrite ^/X.php$ /api/v1/stat last; 它被PHP应用程序的404处理程序捕获。 这里是rewrite_log的nginx错误日志 [notice] 15289#0: *759 "^/X.php$" matches "/X.php", client: 10.0.0.12, server: example.com, request: "GET /X.php HTTP/1.1", host: "example.com" [notice] 15289#0: *759 rewritten data: "/api/v1/stat", args: "", client: 10.0.0.12, server: example.com, request: "GET /X.php HTTP/1.1", host: "example.com" [notice] 15289#0: *759 "^/X.php$" does not match "/index.php", […]
我有以下的Apache重写规则,我试图转换为与Nginx的工作。 RewriteRule ^(.*)\/(.*)-(\d{4})(?:-(.*))?$ album.php?artist=$1&album=$2&releaseyear=$3&extra=$4 我希望它只是 location / { rewrite "^/(.*)\/(.*)-(\d{4})(?:-(.*))?$" /album.php?artist=$1&album=$2&releaseyear=$3&extra=$4; } 虽然这不起作用,但是我的重写规则的nginx版本有没有明确的问题?
有没有办法在HAProxy做URL掩码? 我想有一个URL指向我的负载平衡器,即www.example.com ,redirect到另一个URL我有另一个应用程序。 不过,我希望用户的浏览器仍然显示原始url( www.example.com )。 我将如何去做这件事?
我有一个巨大的引用黑名单,我想停止所有我的网站上的垃圾邮件( https://perishablepress.com/blacklist/ultimate-referrer-blacklist.txt )。 目前我必须更改我的所有虚拟主机文件/ etc / nginx / sites-available / 但是这似乎很难保持。 有没有一种方法或nginx国防部,这有助于我在中央的地方设置重写规则,以便我不必在每个虚拟主机文件中维护它们? 我search了所有的默认模组,并没有能够find一个满足我的要求。
我是一个初学者的Nginx用户试图代理以下内容: http://subdomain.example.com/mypage/login TO http://some_ip_address/login (不只是/login – 该网站也有其他上下文,例如/静态,/ API等) 虽然我可以在function上做到这一点,但用户可以在他们的浏览器中看到http://some_ip_address ,这是我想避免的。 该configuration看起来像这样: worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 3; server { server_name this_server_ip; location /mypage/ { proxy_pass http://some_ip_address; rewrite ^/mypage/(.*)$ http://some_ip_address/$1 last; } location / { root /var/local/directory/; } } } 为了解决这个问题,我尝试了下面的组合: proxy_pass http://some_ip_address/; (即用斜线) proxy_set_header […]
我正在将应用程序从Unix转换到基于Windows的基础架构,其中一个变化是使用apache而不是lighttpd作为Web服务器。 大多数这种转换是直接的,但是我有问题将重写逻辑转换到新的服务器。 花了一天的时间尝试各种configuration后,我没有任何成功。 没有URL被重写,或者它们都是 – 这两种情况都是无效的。 这里是lighttpd规则: "^/$" => "/apex/f?p=314:1::::::", "^/(view)/(\d{10,16})/(\d{1,10})/" => "/apex/f?p=314:ticket:$2::NO::P3_TICKET:$3", "^/(estimate)/(\d{10,16})/(\d{1,10})/" => "/apex/f?p=314:estimate:$2::NO::P6_TICKET:$3", "^/([A-Za-z0-9_-]*)/(\d{10,16})/$" => "/apex/f?p=314:$1:$2::NO:::", "^/([A-Za-z0-9_-]*)/(\d{10,16})/f" => "/apex/f?p=314:$1:$2::NO:::", "^/authenticate/(\d{10,16})/(.*)/$" => "/apex/f?p=314:authenticate:$1::NO::UN,HMAC,TS:$2", "^/authenticate/(\d{10,16})/(.*)/wwv_flow.accept$" => "/apex/wwv_flow.accept", "^/admin/$" => "/apex/f?p=4550:::::::" 这就是我在.htaccess中迄今为止所尝试的: RewriteEngine On RewriteRule ^/(view)/(\d{10,16})/(\d{1,10})/ /apex/f?p=314:ticket:$2::NO::P3_TICKET:$3 [QSA,L] RewriteRule ^/(estimate)/(\d{10,16})/(\d{1,10})/ /apex/f?p=314:estimate:$2::NO::P6_TICKET:$3 [QSA,L] RewriteRule ^/([A-Za-z0-9_-]*)/(\d{10,16})/$ /apex/f?p=314:$1:$2::NO::: [QSA,L] RewriteRule ^/([A-Za-z0-9_-]*)/(\d{10,16})/f /apex/f?p=314:$1:$2::NO::: [QSA,L] RewriteRule ^/authenticate/(\d{10,16})/(.*)/$ /apex/f?p=314:authenticate:$1::NO::UN,HMAC,TS:$2 [QSA,L] RewriteRule […]
我的一个网站不断收到包含查询string的假URL请求。 我有caching,但不幸的是查询string被忽略。 现在每当我收到大量的查询string请求时,我的服务器就会因为命中数据库和PHP处理(我正在使用wordpress)而被钉死,而且我的服务器变得无响应。 我怎么能忽略/重写请求包含查询string的任何url将通过我的后端,但允许他们的静态文件和某些URL(/search/,/ wp-admin /,wp-login.php等)? 我的nginx设置 location ~ \.php$ { fastcgi_index index.php; try_files $uri = 404; include fastcgi_params; fastcgi_split_path_info ^(.+.php)(.*)$; fastcgi_pass unix:/dev/shm/php-fpm-www.sock; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; } # Use cached or actual file if they exists, otherwise pass request to WordPress location / { try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args ; } 有没有一个简单的(ISH)的方式来完成这与重写? 我感到震惊的是,在互联网上我几乎找不到任何其他的信息(也许我没有find正确的解决scheme),我当然不能成为唯一面临这个问题的人。 每个人如何处理?
目前我在我的本地(Apache)做了一个项目设置,在NGINX里。 我在将规则从NGINX转换为.htaccess规则时遇到了麻烦。 有人能帮我把下面的规则转换成.htaccess规则。 location /test/ { set $store_code test; index index.html index.php; try_files $uri $uri/ @handler_test; expires 30d; } 提前感谢。