0

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!

Community
  • 1
  • 1
  • 1
    What is a "secret" redirect? If you return a 301 there'll be nothing secret about it, the address in the browser will change. – arco444 Jun 22 '15 at 09:22
  • what i mean is that i want any page, subpage and resource to display `http://domainname.com/pageorresource` and not `http://domainname.com.someotherstuff.com/pageorresource` also during page load. 301 is something that i read around (trying to find the link in my browser history), not sure if it's relevant in the discussion – ruggerocastagnola Jun 22 '15 at 09:27
  • Yeah, so not relevant in itself for what I'm trying to achieve. I understand there is a tradeoff if the redirect hidden: it is not search engine friendly (for example [this](https://css-tricks.com/snippets/htaccess/301-redirects/)). – ruggerocastagnola Jun 22 '15 at 09:41
  • So, if I understand correctly, you want the user's browser to look up, fetch and display a page for the long name, but show the short name in the URL field? For example, go to `microsoft.com.evil.org` and show their content in the browser window, but say only `microsoft.com` in the URL field? – Calle Dybedahl Jun 22 '15 at 13:40
  • what is the matter of the secrecy ? it seems that this is suitable for phishing. Sorry if I misunderstood –  Jun 22 '15 at 14:46
  • Hi all, yes Calle, that's what I mean. I found a post that kind of explains the problem I'm having. I'm working on a website on a MediaTemple grid hosting, which automatically adds other stuff to your domain name. In [this](http://forum.textpattern.com/viewtopic.php?id=28075) post, the person who wrote to MediaTemple for assistance was told to do a 301 redirect, but it's really ugly to see in terms of design. I was wondering if there's a way to avoid showing it, apart from changing provider. – ruggerocastagnola Jun 23 '15 at 09:59
  • Hi igael, I hope the answer I gave to Calle is enough to answer your question! – ruggerocastagnola Jun 23 '15 at 10:02

1 Answers1

0

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
Community
  • 1
  • 1
Rick Buford
  • 629
  • 3
  • 4