Articles of 重写

如何使用Apache从子文件夹代理到其他服务器

鉴于以下url: domain.com/wiki/ 我想要Apacheredirect下面的所有请求(所以domain.com/wiki/*)otherdomain.com:8080/。 但诀窍是我希望用户总是看到domain.com/wiki/。 其他域的webapp认为它是在根目录下运行的,所以内部链接到css和images,就像/css/style.css一样。 这些url需要重写为/wiki/css/style.css。 以下configuration主要在那里,但是缺less/ css&/ images rewrite解决scheme: ProxyRequests Off ProxyPass /wiki/ http://otherdomain.com:8080/ ProxyPassReverse /wiki/ http://otherdomain.com:8080/ 任何和所有帮助表示赞赏。

NGINX:301重写

我有一个在Nginx中设置的301重写列表。 我想指定完整的uri而不是使用正则expression式。 写这种方式是什么? 这是我认为应该做的事情: rewrite /o-atipico /rogerio-madureira.htm permanent; rewrite /CHANGELOG.txt / permanent; rewrite /MaxLucado / permanent; rewrite /adwords / permanent; rewrite /animals.txt / permanent; rewrite /apresentacao / permanent; rewrite /arquivos / permanent; rewrite /atipico / permanent; rewrite /atipico.com.br / permanent; rewrite /baix / permanent; rewrite /baixe.asp / permanent; rewrite /blog / permanent; rewrite /c / […]

如何在使用Nginx重写的Zend Framework路由中避免index.php

我正试图从默认的Zend框架路线摆脱index.php。 我认为应该在服务器级而不是在应用程序上进行纠正。 (纠正我,如果我错了,但我认为这样做在服务器端更有效)。 我运行Nginx 0.7.1和php-fpm 5.3.3 这是我的nginxconfiguration server { listen *:80; server_name domain; root /path/to/http; index index.php; client_max_body_size 30m; location / { try_files $uri $uri/ /index.php?$args; } location /min { try_files $uri $uri/ /min/index.php?q=; } location /blog { try_files $uri $uri/ /blog/index.php; } location /apc { try_files $uri $uri/ /apc.php$args; } location ~ \.php { […]

nginx重写不包括.php文件?

我有一个nginx的网站configuration,这是完美的redirect所有.html请求通过/index.php 。 但是它不会将test.php重写为/index.php ,而是会抛出一个404错误。 任何人都可以摆脱灯吗? 这是我的网站configuration: server { listen 80 default_server; location / { root /srv/www/htdocs; index index.php; try_files $uri $uri/ /index.php; location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param HTTPS on; # <– add this line fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; } […]

用mod_rewrite强制SSL

我有下面的声明,它完美的工作redirect所有请求“WWW”:80强制浏览器到相同的位置:443 RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^/(.*)$ https://www.mydomain.com/$1 [R=301,L] 但是,我想要做的是,无论https://和.mydomain.com之间的什么 – 在这种情况下,www,但它可以是任何东西,如“www2”或“dev”等 – 我想URL简单地转换为它的SSL等效。 我是新来的mod_rewrite,所以我正在寻找甚至可能的假设子域可以是任何可变长度的字符? 在此先感谢您的帮助。

用.htaccess保护目录

不幸的是,随着我推出的产品,黑名单发现他们可以访问我有zip文件的无保护的目录。 我使用PHP来提供readfile()的zip文件,所以通常在我的应用程序中,用户不会通过URL访问这些文件。 所以,为了解决这个问题,我在这个目录下放了一个空白的index.php文件。 麻烦的是,那些在论坛上看到什么是真正的zip文件名的人可以通过简单地inputurl来下载它,不幸的是我的产品交付系统是复杂的,不会让我改变那个URL的名字。 如何在该目录中创build一个.htaccess文件,以便人们不能通过URL下载任何东西,但是允许我的PHP readfile()代码继续使用force dodwnload提供该文件? 即使你只是猜测 – 我现在正在采取任何build议。 我会继续努力,直到我在这里find有用的东西。 再次,我只需要阻止直接浏览器访问人们在论坛上阅读的特定zip文件的URL。 我认为通过文件系统而不是Web访问的PHP readfile()代码将继续正常工作。

Nginx重写redirect/到一个目录

我正在使用nginx,我试图将http://vhost.domain.com上的所有请求redirect到http://vhost.domain.com/world 我已经浏览了一些网站,但我太菜鸟了,为了获得好的结果,请给我一些帮助? PS:这是我最后一次尝试的: location = /world { rewrite ^ http://vhost.domain.com$uri permanent; } 亲切的问候, 半

Nginx的Googlebot重写规则404失败

我们的网站基于Angular,它几乎完全基于JavaScript,因此我们需要为Googlebot提供静态HTML快照,以便抓取我们。 目前,我们有这个实施: location / { # Rewrite rules for the Google and Bing bots and other crawlers. # Serves static HTML from /snapshots when a URL is requested if ($http_user_agent ~ (Googlebot|bingbot|Screaming)) { rewrite ^/(.*)$ /snapshots/$1.html break; } } 这在大多数情况下都能正常工作,但是如果Google要求一个URL,例如: http://site.com/support/contact/ : http://site.com/support/contact/ ,它将被重写成: http://site.com/support/contact/.html : http://site.com/support/contact/.html显然会返回一个404。我需要更改configuration以在URL末尾删除正斜杠,以确保返回: http://site.com/support/contact.html : http://site.com/support/contact.html 这怎么能在nginxconfiguration中实现呢? 因此,我们在网站站长工具中看到了数百个404错误。 谢谢!

如何显式应用百分比转义到nginx中的URL?

我有以下configuration: location ~ ^/((index\.php|robots\.txt|admin|static|uploads|api)(/.*)?)$ { proxy_set_header Host $http_host; proxy_pass http://localhost:1337/$1?$args; } 我想将转义百分比应用到$1 ,所以例如/admin/foo%20bar会转发/admin/foo%20bar而不是/admin/foo bar 。 我怎样才能做到这一点?

Nginx的反向代理在子域上强制301(不应该)

所以我使用Nginx(1.4.3)来反向代理域和子域。 我安装了SSL证书来处理主域(example.com)和几个子域(可以说test.example.com和mail.example.com)。 所以我自然使用一个301返回将http请求移动到https。 server { listen 80 default_server; server_name example.com www.example.com; return 301 https://example.com$request_uri; } 很好用。 但是,如果我在HTTPS SSL Certs下引入另一个不需要的子域(因为我没有通配证书并且不需要此子域)。 尽pipeserver_name已经被隐式设置了,Nginx似乎还是应用了301。 由于它是1.4.3,我把它们分解在conf.d文件夹中。 我认为这是因为如果我清除我的浏览器caching,并导航到新的子域(sd.example.com),它工作正常,不重写为https。 但是,如果我去主网站(example.com)重写踢,我发送到https://example.com ,没有问题。 但是,如果我尝试返回到sd.example.com,则会被重写为https://sd.example.com,并且会popup一个大红色的错误消息。 任何想法为什么发生这种情况? 我宁愿停止在这一个敲我的头。