Articles of redirect

在.htaccess中将“redirect永久”优先于mod_rewrite

我已经组织了我的巨大.htaccess文件通过redirect永久优先,我想执行,如果发现。 在这种情况下,我不想以后mod_rewrite处理。 有什么办法可以实现吗? 例子: Redirect permanent /products/example.aspx http://www.example.com/products/example/ RewriteCond %{REQUEST_URI} products/([1-9a-zA-Z\s-]+)/ RewriteRule ^products/([0-9a-zA-Z\s-]+)/tutorials(/|\.php)$ /products/$1/help/ [R=permanent,L] 虽然上面没有冲突,我的.htaccess文件是60k大,有一些简单的“redirect永久”似乎被忽略,因为后来的RewriteRules(即redirect模式,而不是)

为什么我的mod_rewriteredirect仅适用于请求的页面,而不是必要的CSS,JS文件?

我正在尝试设置mod_rewrite以使应用程序的URL更好一些。 我有一个skinnable系统,通过query parameter设置皮肤,所以任何下面的链接将触发一个特定的皮肤加载(并存储为cookie): www.mysite.com/index.html?skin=123 我正在尝试使入口链接进入系统,所以我使用这个: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^/(.*)/$ /index.html?app=%1 [L] </IfModule> 这似乎工作正常,所以我正在加载下列链接正确的页面: www.mysite.com/890/ => www.mysite.com/index.html?skin=890 但是,只有我的初始页面被正确加载,所有CSS和JS文件仍然被请求从错误的pathwww.mysite.com/890/与www.mysite.com 题: 我怎么能重写所有请求的文件(CSS,JS,IMG …)被正确redirect,不包括/890/path? 另外,有没有办法使我的重写更通用,以便我可以处理这两个 www.mysite.com/890/ => www.mysite.com/index.html?skin=890 www.mysite.com/890/foo.html => www.mysite.com/foo.html?skin=890 www.mysite.com/890/bar.html => www.mysite.com/bar.html?skin=890 感谢您的光芒!

根据X-Forwarded-For标题从HTTPredirect到HTTPS(使用SSL终止)

我正在寻找redirect从HTTP到HTTPS。 我的Nginx服务器位于一个负载平衡器的后面,它将终止我的SSL,并将所有stream量(HTTP和HTTPS)发送到端口80.唯一的证据,我将不得不指出原始请求是HTTP还是HTTPS是通过X-Forwarded-For由负载平衡器设置的标头。 当原始请求使用HTTP时,是否有一种内置的,廉价的方式来处理Nginx中的redirect? 请记住,我只有一个服务器设置为端口80。

为与HTTPS下的其他域共享IP的域禁用HTTPS

我遇到了一个奇怪的问题,试图禁用一个域的HTTPS,但另一个域有HTTPS。 它们都是在专用服务器上运行的不同网站,共享相同的域名IP地址。 但是,我有一个域没有SSL证书,但另一个。 我想为非authentication域禁用HTTPS,同时使其他域保留在HTTPS上。 我在/etc/nginx/sites-enabled/有两个不同的独立虚拟主机, domain1.org (无HTTPS) server { listen 80; server_name www.domain1.org domain1.org; root /var/www/domain1.org; index index.html index.php index.htm; error_log /var/www/logs/domain1.errors.log; [ … ] domain2.com (使用HTTPS) server { listen 443 ssl; server_name domain2.com www.domain2.com; # INCLUDE SSL CERTIFICATE include sites-enabled/domain2_ssl_include; root /home/domain2/www/www; index index.html index.php index.htm; [ … ] 我已经包含了一个监听端口到domain1.org的端口443,但是一旦我这样做了,我会从Firefox中得到一个中止错误(当访问https://domain1.org时 ): 当前连接不可信任 您已经要求Firefox安全连接到domain1.org,但我们无法确认您的连接是否安全。 我打开了技术资料,看来domain1.org使用的是domain2.com的SSL证书: […]

nginxredirect与DNS名称

我有nginxredirect如: server { listen 127.0.0.1:80; server_name myname.local location / { proxy_pass http://m1.local:8080; } } } 很好。 但是在m1.local的ip地址被改变后 – nginx开始返回“坏的网关”。 看起来像它有caching的IP地址为m1.local。 从nginx电脑的nslookup m1.local显示正确的值,并重新启动nginx修复的情况。 如何说nginx它不应该cachingIP的DNS名称?

apache – 查询string重写规则添加百分比符号

我已经设置了一个重写查询string的规则。 尽pipe正确执行了redirect,但URL的重写查询部分会附加%字符,如下所示: 的index.php?选项= com_finder&视图=search&F = 1&ITEMID = 365&Q =在%2520emperor%2527s%2520new%2520school 代替 的index.php?选项= com_finder&视图=search&F = 1&ITEMID = 365&Q =在%20emperor%-27%20new%20school 重写规则设置如下: RewriteCond %{REQUEST_URI} ^/site-search\.html$ RewriteCond %{QUERY_STRING} ^searchword=(.*)$ RewriteRule ^(.*)$ http://www.example.com/index.php?option=com_finder&view=search&f=1&Itemid=365&q=%1 [L,R=301] 我的目标是重写 网站search.html?search内容= someword 如 全站search?Q = someword 语法有什么不对吗?

Apache:基于URL后缀的代理

我的团队编写了一个内部BI服务器,该服务器通过链接(如/users/daily或/updates/questions生成HTML报告。 服务器是用Grails编写的,它可以和Apache-Tomcat的经典设置完美的结合起来: ProxyPass / http://localhost:8080/ nocanon ProxyPassReverse / http://localhost:8080/ 所以 https://example.com/users/daily 被内部代理 http://localhost:8080/users/daily 并从Tomcat servlet服务。 服务器是成功的,我想部署它三次到3个不同的系统,通过URL后缀( /dev , /stg , /prod )来区分: 这意味着https://example.com/dev/users/daily将从http://localhost:8080/users/daily代理,并且https://example.com/prod/users/daily将从http://localhost:8082/users/daily 。 我已经尝试了一些Apache RewriteRule和ProxyPass规则,但是找不到工作组合。 如何在Apache中使用基于后缀的内部路由来实现内部链接?

NGINX:用前缀重写数字url

我打算让一些旧的URL与我们正在迁移到的新的CMS一起工作,但由于某种原因它不能支持纯粹的数值URL slugs,所以新系统将它们作为“/ calendar / event / old-42 “而不是”/日历/事件/ 42“。 我想重新定向这些纯粹的数字url到他们新的slu </s>。 以下是我想要做的事情: location ~ /calendar/event/(\d+)$ { rewrite ^/calendar/event/$1$ /calendar/event/old-$1 permanent; } 这似乎不工作,只有404,当我去“/日历/事件/ 42”。 有任何想法吗?

使用nginx和多个服务器从端口80redirect到443

首先,我对nginx有点新东西,有点失落……我可惜没有find任何解决办法,所以这是我的问题。 如果这是一个已经存在的问题的重复,我很抱歉,我会很高兴看到答案。 我正在构build我的第一个nginx服务器,我有两个域名,其中一个有很多子域名,我希望在所有这些域名上加上SSLredirect。 问题是,它只能在IPv6监听(这里是默认configuration)下工作一次,如果我把相同的configuration放在其他子域上,nginx不会启动(每个子域都有自己的80→443的服务器configuration文件服务器redirect)。 server { listen 443; listen [::]:443; ## All the config and stuff } server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name www.mydomainna.me mydomainna.me; rewrite ^ https://$server_name$request_uri? permanent; } 这是默认的configuration文件,它像一个魅力。 但是,这是让我感到困惑的是,在这个完全相同的configuration(lessdefault_server)每个单一的子域和我的第二个域名,我必须删除IPv6或Nginx不想开始。 server { listen 443; listen [::]:443; ## All the config and stuff } server { listen 80; server_name subdomain.mydomainna.me; […]

Htaccessredirect

我正在寻找使www.purchase.domain.comredirectpurchase.domain.com,下面是我想要做的一个例子: RewriteCond %{HTTP_HOST} ^www\.purchase\. RewriteRule (.*) http://purchase.DOMAIN_NAME/$1 [L,R] 我需要一个variables来replaceDOMAIN_NAME,只需要购买.domain.com 显然,我可以硬编码purchase.domain.com,但我将需要代码在多个网站上工作。 有什么build议么?