Secretly do a mod_rewrite on domain name

喜你入骨 提交于 2020-01-06 06:45:07

问题


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!


回答1:


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


来源:https://stackoverflow.com/questions/30976145/secretly-do-a-mod-rewrite-on-domain-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!