Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-10-03
16
Medium Priority
?
9,260 Views
Last Modified: 2008-01-09
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!

0
Comment
Question by:R-U-Bn
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 29

Expert Comment

by:chilternPC
ID: 20008169
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
 
LVL 2

Accepted Solution

by:
R-U-Bn earned 0 total points
ID: 20008828
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
 
LVL 29

Expert Comment

by:chilternPC
ID: 20008906
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
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
LVL 15

Expert Comment

by:samri
ID: 20016996
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
 
LVL 2

Author Comment

by:R-U-Bn
ID: 20154359
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
 
LVL 15

Expert Comment

by:samri
ID: 20155050
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
 
LVL 2

Author Comment

by:R-U-Bn
ID: 20164415
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
 
LVL 15

Expert Comment

by:samri
ID: 20174756
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
 
LVL 29

Expert Comment

by:chilternPC
ID: 20175201
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
 
LVL 2

Author Comment

by:R-U-Bn
ID: 20538097
Admin, please remove or mark as self-answered.
Thanks.

Anyone any objeftions?
0
 
LVL 29

Expert Comment

by:chilternPC
ID: 20538879
you managed to answer it by asking this forum -  see your previous comments
0
 
LVL 2

Author Comment

by:R-U-Bn
ID: 20541391
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
 
LVL 29

Expert Comment

by:chilternPC
ID: 20541698
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
 
LVL 2

Author Comment

by:R-U-Bn
ID: 20541761
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
 
LVL 1

Expert Comment

by:modus_operandi
ID: 20587967
Closed, 445 points refunded.
modus_operandi
EE Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question