我正在运行lighttpd 1.4.33,它是从互联网开放的Apache服务器反向代理的。 当从lighttpd服务器的本地地址访问脚本时,GETparameter passing给脚本就好了,我得到了预期的结果。 但是,当通过代理访问脚本(并由以下lighttpd规则重写)时,查询参数似乎完全被删除。 似乎是导致问题的重写规则: $HTTP["host"] =~ "^site\.example\.com$" { # This affects the requests that aren't rewritten below, ie. static stuff server.document-root = "/var/www/example/public" url.rewrite-once = ( "^((?!assets).)*$" => "index.php/$1" ) } 这应该是重写所有URL,以便它们通过index.php中的路由引擎传递,除了/assets目录中的静态内容(静态内容)。 请注意, /assets是/var/www/example/public的子目录,所以这个工作正常。 Lighttpd用下拉参数debugging请求的日志: 2014-07-23 11:36:46: (response.c.310) Request-URI : /foo/bar?someparam=data 2014-07-23 11:36:46: (response.c.311) URI-scheme : http 2014-07-23 11:36:46: (response.c.312) URI-authority: site.example.com 2014-07-23 […]
我无法为Magento扩展程序设置redirect。 请求的url是: example.com/index.php/Cdiscount/Package/download/type/offers/filename/BMS_PREFIX_161d529d7c3ef4b5ae1dca92e2334de6/BMS_PREFIX_161d529d7c3ef4b5ae1dca92e2334de6.zip 但是nginx应该返回: example.com/index.php/Cdiscount/Package/download/type/offers/filename/BMS_PREFIX_161d529d7c3ef4b5ae1dca92e2334de6 代替。 BMS_PREFIX_和.zip之间的部分经常会改变,所以这可能会提取所有提供/位置中的.zip文件请求。 我不是100%确定如果在文件中的文件名 offers/filename/BMS_PREFIX…可configuration为其他东西或更改每个请求,但我认为它不会改变。 所以基本上我需要告诉Nginx在请求example.com/path/时候用example.com/path/回复。 当前configuration: location / { proxy_pass http://127.0.0.1:6081; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_hide_header X-Varnish; proxy_hide_header Via; proxy_hide_header Vary; proxy_hide_header X-Server; proxy_hide_header X-Backend-Server; proxy_hide_header X-Frame-Options; proxy_redirect off; proxy_max_temp_file_size 0; proxy_connect_timeout 7200; proxy_send_timeout 7200; proxy_read_timeout 7200; proxy_buffer_size 256k; proxy_buffers 4 512k; […]
我的任务是pipe理一个带有一堆遗留代码的基础目录的Web应用程序,以及我自己制作的一个子目录,我们正在使用这个API来缓慢地将前端迁移到SPA模型。 主人已经得到了野兔的屁股,并下令将我们移动到Nginx。 我在Apache重写方面有丰富的经验,我需要大约9秒的时间才能在Apache中进行设置。 然而,正如人们很快指出的那样,nginx不是Apache。 虽然我可以让应用程序的任何一部分在nginx中自行工作,但是当它位于/ api /目录中时,我无法让API与主应用程序一起玩。 我猜测这将是位置指令的一些排列,这似乎在Apache中的行为类似。 基本上,如果有什么命中/ api /目录,我需要通过重写将uri的其余部分传递给/api/public/index.php: ^/(.*)$ public/index.php?_url=/$1; 任何帮助是极大的赞赏。 现有configuration: server { listen 10.1.1.225:443 ssl; server_name dev.domain.com; ssl_certificate /etc/nginx/conf.d/chain.crt; ssl_certificate_key /etc/nginx/conf.d/4096_SSL.key; set $root_path '/usr/share/nginx/www'; root $root_path/trunk; index index.php index.html; fastcgi_param ENV development; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; fastcgi_read_timeout 180; location / { try_files $uri $uri/ =404; } location ^~ /api […]
我试图redirectwp-content/uploads/(.*)$到images/$1但这个位置似乎没有redirect – 为什么? 使用try_files会更高效吗? location ^/wp-content/uploads/.*$ { rewrite ^/wp-content/uploads/([a-zA-Z\-.]+)$ /images/$1 302; # try_files /images/$1 =404; }
我们有一个WordPress的安装,需要redirect丢失的密码链接到另一个不同的url,我们试图设置redirect规则,但这是行不通的。 任何人都可以请帮助我们。 location / { proxy_pass http://localhost; } location wp-login.php?action=lostpassword rewrite ^(.*) http://recover.geo.com $1 permanent; } 但是loginurl(wp-login.php?action = login)也会redirect到recover.geo.com 我们只需要redirecturl wp-login.php?action = lostpassword到其他所有的url,包括wp-login.php?action = login需要proxypass 任何人都可以请帮助我们正确的configuration。 谢谢
我有这个重写规则 RedirectRule ^(/arf/sites/.*)$ /docs/saf/files$1 [R=301,I,L] 当它redirect时, $1包含/arf/sites/filename.html所以在redirect之后,访问者结束于 http://domain.com/docs/saf/files/arf/sites/help/filename.html 当我期待他们最终在 http://domain.com/docs/saf/files/filename.html 我如何摆脱$1中的前缀目录 – 或者我做错了吗?
我在我的文档根目录中有一个文件update.php 。 但我不希望/update我的URL直接到update.php(因为我想/update与我的CMS,Drupal 7中的页面相关联) 我知道在Drupal看到Apache之前,Apache正在“处理” /update :我在我的本地开发器上创build了一个新的空文件夹test.dev,在其中放置一个名为orange.html的文件,并且我的浏览器访问了test.dev/orange显示orange.html – 所以这是configurationApache的情况 我的configuration是从puphpet.com Ubuntu12.04 PHP5.5最默认提供的设置 test.conf # ************************************ # Vhost template in module puppetlabs-apache # Managed by Puppet # ************************************ <VirtualHost *:80> ServerName test.dev ## Vhost docroot DocumentRoot "/var/www/test.dev" ## Directories, there should at least be a declaration for /var/www/test.dev <Directory "/var/www/test.dev"> Options Indexes FollowSymLinks MultiViews AllowOverride All […]
我有以下重写nginx的规则。 规则似乎无法正常工作,例如游戏规则应该将http://thegamesdb.net/game/2/重写为http://thegamesdb.net/index.php?tab=game?id=2当我导航到/游戏/ 2 /浏览器正在下载一个名为简单download的文件hover。 我的重写规则如下: # nginx configuration location /game { rewrite ^/game/([0-9]+)(/?)$ /index.php?tab=game&id=$1 break; rewrite ^/game-edit/([0-9]+)(/?)$ /index.php?tab=game-edit&id=$1 break; } location /search { rewrite ^/search/([a-z0-9\-\ /\+]+)(/?)$ index.php?tab=listseries&string=$1&function=Search break; rewrite ^/search(/?)$ /index.php?tab=listseries&function=Search break; } location /browse { rewrite ^/browse/([0-9+]*)(/?)$ /index.php?tab=listplatform&stringPlatform=$1&function=Browse+By+Platform break; } location /platform { rewrite ^/platform/([0-9]+)(/?)$ /index.php?tab=platform&id=$1 break; rewrite ^/platform/([a-z0-9\-]+)(/?)$ /index.php?tab=platform&alias=$1 break; rewrite ^/platform-edit/([0-9]+)(/?)$ /index.php?tab=platform-edit&id=$1 […]
我有2个网站, http://localhost/bb – phpbb http://localhost/dp – Drupal 我希望将$server_name/bb/ucp.php?mode=logout&sid=xxxxxredirect到$server_name/dp/user/logout ,sid应该被忽略。 我试过这个: location /bb/ { index index.php; if ($query_string ~* "mode=logout$") { rewrite ^/bb/ucp\.php http://$server_name/dp/user/logout redirect; } } 这似乎不工作。 谁能帮忙? 谢谢。 我也试过这个: location /bb/ { index index.php; if ($arg_mode ~* "logout") ## and = instead of ~* too. { rewrite ^/bb/ucp\.php http://$server_name/dp/user/logout redirect; } } 但它也不起作用。 当前整个configuration: […]
我目前正在为我们公司设置新的服务器,而且我们正在开发很多不同的应用程序,现在我们要在wp.domain.com/app1,wp.domain.com/app2等所有的wordpress应用程序中。 默认不工作的原因是因为我们想为所有的应用程序使用%postname%permalink。 我目前正在通过对每个子文件夹进行重写来进行pipe理,但是我宁愿用一个location块来重写每个子文件夹,所以每当我们上传一个新的应用程序到服务器时,我都不必编辑服务器块。 我们也有可能上传到子目录,例如wp.domain.com/appgroup1/app3,wp.domain.com/appgroup1/app6等。 这是我的wp.domain.comconfiguration: server { listen 80; root /usr/share/nginx/html/wp; index index.php index.html index.htm; server_name wp.domain.com; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location ~ /(.*)/ { index index.php; try_files $uri $uri/ /$1/index.php?$args; } […]