FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » HTTP headers and header()
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
HTTP headers and header() [message #176642] Fri, 13 January 2012 20:47 Go to next message
Sandman is currently offline  Sandman
Messages: 32
Registered: August 2011
Karma: 0
Member
Hello,
I run a website which allows users to create profiles for
themselves, i.e. example.com/user. Recently I've had a request for
custom domains, i.e. where vanity.user.com would take a browser to
example.com/user.

Using my own domain, I changed vanity.user.com so it resolves to
the IP address of my webserver. Since I run apache, I created a
RewriteRule so if the HOST header matched vanity.user.com it would
redirect permanently to example.com/user.

Upon redirection however, the location bar in my browser updates
to example.com/user. Does anyone know if there is a way to:

1. Redirect the vanity domain to the user's profile.
2. Keep the location bar the same (i.e. vanity.user.com)

I'm cross-posting to comp.lang.php because I was wondering if the
header() function might help.

Thanks!
Sandman
Re: HTTP headers and header() [message #176643 is a reply to message #176642] Fri, 13 January 2012 22:07 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Sandman wrote:
> Hello,
> I run a website which allows users to create profiles for
> themselves, i.e. example.com/user. Recently I've had a request for
> custom domains, i.e. where vanity.user.com would take a browser to
> example.com/user.
>
> Using my own domain, I changed vanity.user.com so it resolves to
> the IP address of my webserver. Since I run apache, I created a
> RewriteRule so if the HOST header matched vanity.user.com it would
> redirect permanently to example.com/user.
>
> Upon redirection however, the location bar in my browser updates
> to example.com/user. Does anyone know if there is a way to:
>
> 1. Redirect the vanity domain to the user's profile.
> 2. Keep the location bar the same (i.e. vanity.user.com)
>
> I'm cross-posting to comp.lang.php because I was wondering if the
> header() function might help.
>
> Thanks!
> Sandman
set up an apache virtual server and do the thing properly
Re: HTTP headers and header() [message #176644 is a reply to message #176642] Fri, 13 January 2012 22:32 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 13.01.2012 21:47, schrieb Sandman:
> Hello,
> I run a website which allows users to create profiles for
> themselves, i.e. example.com/user. Recently I've had a request for
> custom domains, i.e. where vanity.user.com would take a browser to
> example.com/user.
>
> Using my own domain, I changed vanity.user.com so it resolves to
> the IP address of my webserver. Since I run apache, I created a
> RewriteRule so if the HOST header matched vanity.user.com it would
> redirect permanently to example.com/user.
>
> Upon redirection however, the location bar in my browser updates
> to example.com/user. Does anyone know if there is a way to:
>
> 1. Redirect the vanity domain to the user's profile.
> 2. Keep the location bar the same (i.e. vanity.user.com)
>
> I'm cross-posting to comp.lang.php because I was wondering if the
> header() function might help.
>
> Thanks!
> Sandman

Get acquainted with Apache VirtualServer and ServerName directives.

/Str.
Re: HTTP headers and header() [message #176645 is a reply to message #176644] Fri, 13 January 2012 22:33 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 13.01.2012 23:32, schrieb M. Strobel:
> Am 13.01.2012 21:47, schrieb Sandman:
>> Hello,
>> I run a website which allows users to create profiles for
>> themselves, i.e. example.com/user. Recently I've had a request for
>> custom domains, i.e. where vanity.user.com would take a browser to
>> example.com/user.
>>
>> Using my own domain, I changed vanity.user.com so it resolves to
>> the IP address of my webserver. Since I run apache, I created a
>> RewriteRule so if the HOST header matched vanity.user.com it would
>> redirect permanently to example.com/user.
>>
>> Upon redirection however, the location bar in my browser updates
>> to example.com/user. Does anyone know if there is a way to:
>>
>> 1. Redirect the vanity domain to the user's profile.
>> 2. Keep the location bar the same (i.e. vanity.user.com)
>>
>> I'm cross-posting to comp.lang.php because I was wondering if the
>> header() function might help.
>>
>> Thanks!
>> Sandman
>
> Get acquainted with Apache VirtualServer and ServerName directives.
>
> /Str.

Ops, VirtualHost
Re: HTTP headers and header() [message #176646 is a reply to message #176642] Sat, 14 January 2012 01:40 Go to previous messageGo to next message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
Sandman, 2012-01-13 21:47:

> Hello,
> I run a website which allows users to create profiles for
> themselves, i.e. example.com/user. Recently I've had a request for
> custom domains, i.e. where vanity.user.com would take a browser to
> example.com/user.
>
> Using my own domain, I changed vanity.user.com so it resolves to
> the IP address of my webserver. Since I run apache, I created a
> RewriteRule so if the HOST header matched vanity.user.com it would
> redirect permanently to example.com/user.
>
> Upon redirection however, the location bar in my browser updates
> to example.com/user. Does anyone know if there is a way to:
>
> 1. Redirect the vanity domain to the user's profile.
> 2. Keep the location bar the same (i.e. vanity.user.com)

This is not possible. *Either* redirect *OR* keep the location.

If you don't want this, you have to set up a virtual host in Apache
which acts as a proxy for example.com/user.


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Re: HTTP headers and header() [message #176647 is a reply to message #176646] Sat, 14 January 2012 02:58 Go to previous messageGo to next message
Sandman is currently offline  Sandman
Messages: 32
Registered: August 2011
Karma: 0
Member
Thanks Arno. I thought as much, but thank you for confirming.

I had wanted vanity.user.com to resolve to example.com/user.
It seems there are only 2 possible half-solutions:
1. Use redirects, which change the location bar as I mentioned
originally.
2. Use VirtualHosts which does not change the location bar. But with
this solution, vanity.user.com/user resolves to example.com/user.
Which is not really what I wanted.

Ah well, my users will have to live with this.

Regards,
Sandman


On Jan 13, 5:40 pm, Arno Welzel <use...@arnowelzel.de> wrote:
> Sandman, 2012-01-13 21:47:
>> Hello,
>>    I run a website which allows users to create profiles for
>> themselves, i.e. example.com/user. Recently I've had a request for
>> custom domains, i.e. where vanity.user.com would take a browser to
>> example.com/user.
>
>>    Using my own domain, I changed vanity.user.com so it resolves to
>> the IP address of my webserver. Since I run apache, I created a
>> RewriteRule so if the HOST header matched vanity.user.com it would
>> redirect permanently to example.com/user.
>
>>     Upon redirection however, the location bar in my browser updates
>> to example.com/user. Does anyone know if there is a way to:
>
>> 1. Redirect the vanity domain to the user's profile.
>> 2. Keep the location bar the same (i.e. vanity.user.com)
>
> This is not possible. *Either* redirect *OR* keep the location.
>
> If you don't want this, you have to set up a virtual host in Apache
> which acts as a proxy for example.com/user.
>
> --
> Arno Welzelhttp://arnowelzel.dehttp://de-rec-fahrrad.de
Re: HTTP headers and header() [message #176648 is a reply to message #176647] Sat, 14 January 2012 07:51 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
Sandman wrote:

> 2. Use VirtualHosts which does not change the location bar. But with
> this solution, vanity.user.com/user resolves to example.com/user.
> Which is not really what I wanted.

Thenk yo haven't set up the virtualhost correctly, instead of redirecting with
mod_rewrite, you set the documentroot to the actual directory which is the
same as it would have been for example.com/user.
If the directory depends on a CMS, then you need to employ the usage of
mod_proxy in the virtualhost, which fetches the files from example.com/user.

In both these cases the domain will be kept as the original one which the
visitor typed in the browser.


Did set the follow up to alt.apache.configuration as that is the newsgroup
where this thread should have been all the time.

--

//Aho
Re: HTTP headers and header() [message #176649 is a reply to message #176647] Sat, 14 January 2012 09:37 Go to previous messageGo to next message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
Sandman, 2012-01-14 03:58:

> Thanks Arno. I thought as much, but thank you for confirming.
>
> I had wanted vanity.user.com to resolve to example.com/user.
> It seems there are only 2 possible half-solutions:
> 1. Use redirects, which change the location bar as I mentioned
> originally.
> 2. Use VirtualHosts which does not change the location bar. But with
> this solution, vanity.user.com/user resolves to example.com/user.
> Which is not really what I wanted.

Why is it neccessary to use vanity.user.com/user?

BTW: Please learn, how to quote properly in usenet postings (quotation
above, reply below) - thanks!


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Re: HTTP headers and header() [message #176651 is a reply to message #176647] Sat, 14 January 2012 11:09 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Sandman wrote:
> Thanks Arno. I thought as much, but thank you for confirming.
>
> I had wanted vanity.user.com to resolve to example.com/user.
> It seems there are only 2 possible half-solutions:
> 1. Use redirects, which change the location bar as I mentioned
> originally.
> 2. Use VirtualHosts which does not change the location bar. But with
> this solution, vanity.user.com/user resolves to example.com/user.
> Which is not really what I wanted.
>

Bullshit. Set the root directory of example.com to be the same directory
as vanity.user.com/user

You are just being lazy.
Re: HTTP headers and header() [message #176652 is a reply to message #176642] Sat, 14 January 2012 14:26 Go to previous messageGo to next message
Jonathan Stein is currently offline  Jonathan Stein
Messages: 43
Registered: September 2010
Karma: 0
Member
Den 13-01-2012 21:47, Sandman skrev:

> Using my own domain, I changed vanity.user.com so it resolves to
> the IP address of my webserver. Since I run apache, I created a
> RewriteRule so if the HOST header matched vanity.user.com it would
> redirect permanently to example.com/user.

How did you do this? Rewrites should not issue a redirect unless you
specifically ask for it (with the "R" flag in Apache).

Now that you're posting in the PHP group, you could also rewrite ALL
requests that do NOT have example.com as the host to a PHP script and
let that script look op the userprofile to show.

Start with the Apache documentation - there ain't much you can't do with
a rewrite. ;-)

Regards

Jonathan
Re: HTTP headers and header() [message #176740 is a reply to message #176642] Fri, 20 January 2012 15:34 Go to previous message
Miquel van Smoorenbur is currently offline  Miquel van Smoorenbur
Messages: 1
Registered: January 2012
Karma: 0
Junior Member
In article <d16b12f4-efb0-46e7-a585-a4c143c33818(at)a8g2000pbi(dot)googlegroups(dot)com>,
Sandman <enjoylife_95135(at)hotmail(dot)com> wrote:
> Upon redirection however, the location bar in my browser updates
> to example.com/user. Does anyone know if there is a way to:
>
> 1. Redirect the vanity domain to the user's profile.
> 2. Keep the location bar the same (i.e. vanity.user.com)

Sure. Use mod_rewrite, match on the Host header, and alias
to /user/

Say you want to map USER.vanity.com -> example.com/USER :

RewriteCond %{HTTP_HOST} ^(.*)\.vanity\.com$ [NC]
RewriteRule ^/(.*)$ /%1/$1

If you use this in a VirtualHost section make sure you
set ServerAlias *.vanity.com.

You might want to exclude /cgi-bin or other paths from this
specifically, you might want to add the [PT] flags to the
rewriterule .. see http://httpd.apache.org/docs/current/mod/mod_rewrite.html
for the details

Assuming apache, ofcourse.

Mike.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: error from phpadmin
Next Topic: list() Struktur auslagern
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 21:34:06 GMT 2024

Total time taken to generate the page: 0.02015 seconds