Silent or invisible or transparent redirect (.htaccess or different)

Hello,

I try to do the following:  
When a user types ..
         http://www.tec4dec.be(anything here)  (let's call this A)
...he would come to...
         http://tec4dev.be/www(anything here)  (let's call this B)
.. BUT without the user seeing B in his address bar or as URL. So the user would still see A!

The following works, but is not silent (so the user sees B): in .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.tec4dev.be [NC]
RewriteRule ^(.*)$ http://tec4dev.be/www/$1 [L,R=301]  

When I remove the ",R+301" I get a 500 Internal Server Error .

Please help!

LVL 2
R-U-BnAsked:
Who is Participating?
 
R-U-BnConnect With a Mentor Author Commented:
Hmm..I am not so good at .htaccess, what should I type?
I tried the following without success:

<VirtualHost *>
ServerName www.tec4dev.be/www
ServerAlias www.tec4dev.be
</VirtualHost>
---> Server Error

<VirtualHost *>
DocumentRoot /public_html/www
ServerName www.tec4dev.be
</VirtualHost>
---> Server Error (with absolute path, same)

By the way, I am using a hosting provider, I don't have access to all directories, maybe that's why, I dunno.

Anyway, your URL made me search some further and I found the solution (heavens know how):
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.* [NC]
    RewriteRule ^(.*) /www/$1 [L]

Anyway, thanks for trying.
0
 
Peter HartCommented:
I use alias's for this function so when people type in www.chilternpc.co.uk  they get www.chilternpc.com  content, but the address is still www.chilternpc.co.uk

so can you not set  "web addressA" as an alias to "websaddressB"

to do this in apache see
http://forums.macosxhints.com/showthread.php?t=45712


0
 
Peter HartCommented:
you are correct -
if you have a hosting provider do they provide an interface to set up alias's?

try
<Host name="www.mycompany.com" ...>
  ...
  <Alias>mycompany.com</Alias>
  ...
</Host>



0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
samriCommented:
hi R-U-Bn,

When a user types ..
         http://www.tec4dec.be(anything here)  (let's call this A)
== I would assume that there is a slash (/) after the ".be". otherwise DNS resolution may failed.
         http://www.tec4dec.be/(anything here)  (let's call this A)

mod_rewrite should be able to do the job, like you posted.  However, I have very limited skills on that.

I am personally more comfortable to propose using the ProxyPass/ProxyPassReverse for this.

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse

<VirtualHost *>
  ServerName www.tec4dev.be
  ServerAlias tec4dev.be
  ProxyPass            /     http://tec4dev.be/www/ 
  ProxyPass            /     http://tec4dev.be/www/
</VirtualHost>

in the respective server Vhost container for      www.tec4dec.be

cheers.
0
 
R-U-BnAuthor Commented:
samri, I get a Server Error with your code.. (I should put that in .htaccess, right?)
Are you sure nothing is lacking (like  ProxyRequests On or so?) or you need 2 times the same line there?
Secondly, do you know if your solution is better than mine?
0
 
samriCommented:
hi R-U-Bn,

sorry for taking a bit while to respond.

You would need to add it to the server config.  What is your server OS, and apache version by the way?

You also may want to check the docs for mod_proxy - http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

You would need to load the proxy module first.  In the config file (httpd.conf), look for the following line, and uncomment it (remove the # in the beginning of the line).

LoadModule proxy_module modules/mod_proxy.so

However!! If I relook at the initial question text;

When a user types ..
         http://www.tec4dec.be(anything here)  (let's call this A)
...he would come to...
         http://tec4dev.be/www(anything here)  (let's call this B)
.. BUT without the user seeing B in his address bar or as URL. So the user would still see A!

what you wanted to do is having the user visiting http://www.tec4dec.be/anylink/any.html and the content is served from:

http://tec4dev.be/www/anylink/any.html

So rather than complicating the subject, It would be easier to reconfigure the DocumentRoot for the server wherever the "www" forlder is.

And, in apache config, look at ServerName and ServerAlias directive.  In your case, you could do

ServerName tec4dev.be
ServerAlias   www.tec4dev.be

DocumentRoot /path/to/www

Theese needs to be in httpd.conf, and not .htaccess file.  The rewrite rule would work in .htacces though.

cheers.

0
 
R-U-BnAuthor Commented:
I see now, samri.  Like I said, I am using a hosting provider, so I don't have access to those configs you are talking about. (www is even pre-programmed elsewhere)  I presume it won't work with your solution then..
Thanks anyway. :-}
0
 
samriCommented:
hi R-U-Bn,

my apology on missing that fact :(.

Perhaps you could highligh this to you Hosting provider.  

Typically, most hosting provider would implement VirtualHosting for the client websites.  As such, the ServerName and ServerAlias directive should be in place, or could be added.

And the thing about contents coming from /path//www/ is DocumentRoot (or web home, or anything they may called it).  Should also be configurable.

Mod_rewrite, should be able to do this, and could be used in .htaccess file.  However, I do not have that much knowledge on that unfortunately.

There are docs docs/guide on Apache website that you could take a look:

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide_advanced.html

** which I had spent some time, and doesn;t quite make it into my head :(


Cheers,
0
 
Peter HartCommented:
I use alias all the time with my hosting company - this is how it works with mine - it may help -

register ALL the domain names  with your hosting company then  
use one of them as the host  and upload your files and set up all the others as alias's to this one
This is done using the hosting company's interface during domain registration
0
 
R-U-BnAuthor Commented:
Admin, please remove or mark as self-answered.
Thanks.

Anyone any objeftions?
0
 
Peter HartCommented:
you managed to answer it by asking this forum -  see your previous comments
0
 
R-U-BnAuthor Commented:
I completely agree.  But since I can't mark my own answer as answer (possibly with you getting the points as support), xX possibilities doesn't allow me to do this properly.

Let's do it like this maybe, chilternPC, just repeat my answer and I can accept your repetition, agree?
0
 
Peter HartCommented:
you can split the points to everyone you consider helped you to your answer. or you can ask for a point point refund here:
http://www.experts-exchange.com/Other/Community_Support/Top_Solutions_3.html
0
 
R-U-BnAuthor Commented:
You don't understand, chilternPC, I want to give you points, but with my answer.  For future users, you know, to allow them a correct answer.  And at the same time giving you points for pointing me the right way.  For that, there is no way in xX, except what I proposed.

It's your last chance, better take it.  ;-)
0
 
modus_operandiCommented:
Closed, 445 points refunded.
modus_operandi
EE Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.