Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

automatically converting a URL to www

by mike_hi (Initiate)
on Feb 11, 2014 at 22:00 UTC ( #1074525=perlquestion: print w/ replies, xml ) Need Help??
mike_hi has asked for the wisdom of the Perl Monks concerning the following question:

Suppose my site url is www.site.com. Is there a way, when someone logs in to my site using site.com (without the www) or usingt the IP #.com to automatically change their url to www.site.com without having to us an absolute URL. What is happening is that the login cookie gets lost when the various urls on the site change. So I'd like to make everyone start by being www.site.com. Can this be done through a form? Hope this makes sense. Thanks, Mike

Comment on automatically converting a URL to www
Re: automatically converting a URL to www
by choroba (Abbot) on Feb 11, 2014 at 22:03 UTC
    What web server do you run?
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: automatically converting a URL to www
by jethro (Monsignor) on Feb 11, 2014 at 22:12 UTC

    Yes, (in case you run apache) the easiest way is to create a virtual host that redirects to the generic address. See for example http://blog.bartlweb.net/2011/04/redirect-via-apache-virtualhost/ for the simple recipe.

Re: automatically converting a URL to www
by Your Mother (Canon) on Feb 11, 2014 at 23:23 UTC

    Since this is an entirely Perl-free question I’ll offer my free 2¢. …What?

    You’re doing it backwards. Shorter URLs are better. This isn’t 1998 and no one ever wants to have to say out loud, “double-u, double-u, double-u, dot.”

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1074525]
Approved by GotToBTru
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-09-18 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (113 votes), past polls