Forum Moderators: phranque

Message Too Old, No Replies

Masking URL

         

cbrknight

6:35 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



I appologize if this question has been answered before. I am sure it has been asked. I am fairly new to apache server but was asked by my boss to work on this problem

He is running his own apache server. We have a web mall set up on his server.

ie.... www.webmall.com/catalog

He has several other sites that people can use

www.site1.com
www.site2.com

customers sign up for access to his services from either of his site. We would like them to both be able to use the web mall but dont want to have to duplicate the webmall....

Is there any way to mask the site so someone coming from either site would only see their url...

ie...

www.site1.com/catalog
www.site2.com/catalog

Thanks

sitz

7:34 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



If the content is going to be identical for all of them, there's a REALLY easy solution:

  • point DNS for www.site1.com and www.site2.com to the same IP address that www.webmall.com has
  • Configure Apache to response to those hostnames as well (if needed). You'll need to do this if you're using name-base virtualhosts, you won't if you're using IP-based virtualhosts (or just have everything in the main server config).

    Note that some people prefer issuing redirects from www.site1.com to www.mainsite.com, since (I believe, someone check me on this) it can help with search-engine rankings if you don't have identical content on multiple sites. If you opt for issuing a redirect, there are numerous examples of setting this up in the forum archives; it seems to come up at least once a week. =)

    Good luck.

  • cbrknight

    7:49 pm on Mar 25, 2005 (gmt 0)

    10+ Year Member



    Sorry... I said I was new to apache configuration... Most of that sounds like gibberese to me....

    All of the sites he runs on his server have their own IP address and domain...

    I want people to be able to go to the origial domains... so they can sign up for services at the different domains....

    But say they are on

    www.site1.com

    when they click on the shopping cart button... they go to the www.webmall.com/catalog page which is the shopping cart.... however their url in the address box of the browser still says

    www.site1.com/catalog

    Is that what a redirect will do? I always thought that a redirect will move anyone coming intow www.site1.com automatically to www.webmall.com/catalog... this is not what I want to happen....

    Be gentle... I am trying to understand... but the apache documentation reads like the Encyclopedia Galactica....

    Thx

    sitz

    4:41 am on Mar 26, 2005 (gmt 0)

    10+ Year Member



    Yeah, a redirect would move them to the new site. Since that's not an option, the solution will depend on whether these three sites are hosted on the same physical hardware or not. If they are, a mod_rewrite solution is possible; mod_rewrite allows, among other things, transparent rewriting of requests to other paths on the same system. However, the nature of your catalog application *may* preclude this.

    If the transparent rewrite solution is unworkable for some reason, a proxy-based solution may be the way to go. So, questions requiring answering:

  • Are all three sites on the same gear?
  • Do you have write access to httpd.conf?
  • How much work are you willing to do to make this work? =)
  • cbrknight

    1:06 am on Mar 28, 2005 (gmt 0)

    10+ Year Member



    If the transparent rewrite solution is unworkable for some reason, a proxy-based solution may be the way to go. So, questions requiring answering:

    # Are all three sites on the same gear?

    all on the same server...

    # Do you have write access to httpd.conf?

    have access to everything

    # How much work are you willing to do to make this work? =)
    What ever it takes.... I have perused the mod-rewrite documentation... couldnt decipher it. wasnt sure if it was what I needed or not.... Could you point me in the right direction?

    sitz

    10:53 pm on Mar 28, 2005 (gmt 0)

    10+ Year Member



    OK, so the easy solution, *if* your application will allow it, is something like this:

    NameVirtualHost 192.168.1.1:80
    <VirtualHost 192.168.1.1:80>
    ServerName www.site1.com
    Alias /catalog /path/to/www.webmall.com/htdocs/catalog
    (other directives for this virtualhost here)
    </VirtualHost>

    <VirtualHost 192.168.1.1:80>
    ServerName www.site2.com
    Alias /catalog /path/to/www.webmall.com/htdocs/catalog
    (other directives for this virtualhost here)
    </VirtualHost>

    Alternatively, this could be handled on the filesystem by using symlinks; check the ln(1) manpage for details on this.

    Does this help?

    cbrknight

    3:54 pm on Mar 29, 2005 (gmt 0)

    10+ Year Member



    Sure just one more question... does this go in the webmall htaccess or the htaccess for the other sites?

    jdMorgan

    9:05 pm on Mar 29, 2005 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    It goes in httpd.conf - the server config file.

    Jim

    cbrknight

    9:54 pm on Mar 30, 2005 (gmt 0)

    10+ Year Member



    OK Here is what I did...

    NameVirtualHost 192.168.1.222:80
    <VirtualHost 192.168.1.222:80>
    ServerName www.site1.com
    Alias /catalog C:\apache2\htdocs\vhosts\webmall.com\catalog
    </VirtualHost

    the only thing I thought could be wrong was the /catalog

    the actual folder it is coming from is www.site1.com/validation

    Any idea why it is not working?

    sitz

    10:23 pm on Mar 30, 2005 (gmt 0)

    10+ Year Member



    Alias /catalog C:\apache2\htdocs\vhosts\webmall.com\catalog

    With this, a request for www.site1.com/catalog will pull content from C:\apache2\htdocs\vhosts\webmall.com\catalog. You can change the LHS (left-hand-side) of the 'Alias' directive to be /validation if you'd prefer; it's free-form text. It could be '/orangejuice' or '/cookiemonster'; it's just the URL the browser will have to go to to access the directory listed on the RHS of the Alias directive. =)

    cbrknight

    11:06 pm on Mar 30, 2005 (gmt 0)

    10+ Year Member



    Ok then any idea why it is not working?

    If it helps there is a submit button that when the user information is submitted the database then it sends them to the catalog via
    header(Location:www.webmall.com/catalog)

    sitz

    11:25 am on Mar 31, 2005 (gmt 0)

    10+ Year Member



    What does 'not working' mean? 404? 403? 500? Small gnomes running around the server room with no pants on screaming "THE PURPLE! IT BURNS!"? Is there anything in the logs? Just saying "it doesn't work" is useless. =)

    cbrknight

    4:13 pm on Mar 31, 2005 (gmt 0)

    10+ Year Member



    DOH! sorry...

    when i log in from www.site1.com/validation it sends me to www.webmall.com/catalog but doesnt have the virtual address www.site1.com

    I dont see any errors in the log files...

    The access logs for www.site1.com just have the standard entry for successful access of www.site1.com/validation

    cbrknight

    11:55 am on Apr 4, 2005 (gmt 0)

    10+ Year Member



    NameVirtualHost 192.168.1.1:80
    <VirtualHost 192.168.1.1:80>
    ServerName www.site1.com
    Alias /catalog /path/to/www.webmall.com/htdocs/catalog
    (other directives for this virtualhost here)
    </VirtualHost>

    In this code....

    the url for NameVirtualHost....

    where is this url supposed to be for?

    cbrknight

    12:54 pm on Apr 4, 2005 (gmt 0)

    10+ Year Member



    I finally got the Alias to work...

    But once I am in the webmall if they click on the link it changes back to www.webmall.com/ is there any way to keep the alias working for all the links in the webmall?

    sitz

    3:00 am on Apr 5, 2005 (gmt 0)

    10+ Year Member



    That would seem to imply one of two things; that the HTML had the full URL in it; something along the lines of <a href="http://www.webmall.com/catalog/">link</a>, or that (possibly) you have 'UseCanonicalName on' on your httpd.conf. If the former, your HTML may need to be re-coded. If the latter, you could set 'UseCanonicalName off'. If neither...well, then it's something else. =)

    cbrknight

    4:16 pm on Apr 5, 2005 (gmt 0)

    10+ Year Member



    Well the UseCanonicalNames is off... and I already thought about the hard coded path in my html and fixed that the other day...

    ALL I can figure now is that it is the cart. It is an OSCommerce shopping cart that uses both a physical and virtual path for URL's it must be taking them from the configuration instead of the $_referrer...

    I doubt there is a way around this but you would probably know better than I.