秘密地在域名上做一个mod_rewrite [英] Secretly do a mod_rewrite on domain name

查看:248
本文介绍了秘密地在域名上做一个mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用mod_rewrite问题。基本上我需要对域名执行一个秘密重定向,从

  http://domainname.com.someotherstuff.com 

  http://domainname.com 

此规则也应影响所有子目录。 / p>

我明白有三个步骤:


  1. 告诉系统是否路径匹配我们正在寻找的内容

  2. 定义RewriteRule

  3. 将新路径传递给旧路径,以便系统知道(即使没有显示)两个匹配

我查找了几个帖子和资源(最接近的是这个这个),但没有一个可以一次解决我的问题 - 重写和保密。



有人可以指出我的方向吗?



<另外,有人可以解释隐藏的重定向与301之间的权衡吗?隐藏的重定向不是搜索引擎友好,正确吗?



非常感谢!

解决方案

重写vs重定向



如果您希望客户的浏览器说 http://domainname.com ,但从 http://domainname.com.someotherstuff.com ,那么你想要的是重写。您将把您的客户指向 http://domainname.com 和应答前端(服务器/ LB / etc ...) )然后将domainname.com重写为domainname.com.someotherstuff.com,并将请求发送到将回应该请求的后端服务。在这种情况下,我更喜欢SNAT,所以后端直接响应前端,然后将内容返回给客户,而不是更聪明。



您有几个移动部件:


  1. domainname.com和domainname.com.someotherstuff.com的DNS条目

  2. frontend - F5是我的最爱,但您可以使用任何linux服务器实现类似的结果;需要能够解析domainname.com.someotherstuff.com并且具有到后台的网络连接;服务 http://domainname.com 的请求

  3. 后端 - Web服务器;针对 http://domainname.com.someotherstuff.com 的前端服务请求


I'm struggling with a mod_rewrite problem. Basically I need to do a secret redirect on the domain name, going from

http://domainname.com.someotherstuff.com

to

http://domainname.com

This rule should affect all subdirectories as well.

I've understood there are three steps:

  1. tell the system if the path matches what we're looking for
  2. define the RewriteRule
  3. pass the new path to the old one so that the system knows (even if it doesn't show) that the two match

I've looked up several posts and resources (the closest ones being this and this) but none of them can solve both my problems – rewriting and secrecy – at once.

Can anybody point me in the right direction?

Moreover, can someone explain the tradeoff between a hidden redirect and a 301? Hidden redirect is not search engine friendly, correct?

Thanks a lot!

解决方案

referring to an older post for clarification on rewrite vs redirect

If you want the customer's browser to say http://domainname.com, but fetch the content from http://domainname.com.someotherstuff.com, then what you want is a rewrite. You will point your customer at http://domainname.com and that answering frontend (server/LB/etc...) will then rewrite "domainname.com" to "domainname.com.someotherstuff.com" and send the request on to a backend service that will answer that request. I prefer to SNAT in this case, so the backend responds directly to the frontend, which then returns the content to the customer none the wiser.

You have several moving parts here:

  1. DNS entries for domainname.com and domainname.com.someotherstuff.com
  2. frontend - F5s are my favorites, but you can achieve similar results with any linux server; needs to be able to resolve domainname.com.someotherstuff.com and has network connectivity to the backend; servicing requests for http://domainname.com
  3. backend - web server; servicing requests from frontend for http://domainname.com.someotherstuff.com

这篇关于秘密地在域名上做一个mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆