Apache htaccess and perl

Discussion in 'Perl Misc' started by robertutah@gmail.com, Aug 5, 2006.

  1. Guest

    Hi all

    I have a apache running with mod_perl, it is set up with access-control
    by a .htaccess-file with more than 1 user in it.

    I need to get the username from the one that have logged in. How do I
    do that ?
     
    , Aug 5, 2006
    #1
    1. Advertising

  2. David Squire Guest

    wrote:
    > Hi all
    >
    > I have a apache running with mod_perl, it is set up with access-control
    > by a .htaccess-file with more than 1 user in it.
    >
    > I need to get the username from the one that have logged in. How do I
    > do that ?
    >


    It's a standard CGI environment variable: REMOTE_USER

    You get access to environment variables in Perl via the %ENV hash.


    DS
     
    David Squire, Aug 5, 2006
    #2
    1. Advertising

  3. Guest

    David Squire skrev:

    > wrote:
    > > Hi all
    > >
    > > I have a apache running with mod_perl, it is set up with access-control
    > > by a .htaccess-file with more than 1 user in it.
    > >
    > > I need to get the username from the one that have logged in. How do I
    > > do that ?
    > >

    >
    > It's a standard CGI environment variable: REMOTE_USER
    >
    > You get access to environment variables in Perl via the %ENV hash.
    >
    >
    > DS


    For some resson REMOTE_USER i not in %ENV ?
     
    , Aug 5, 2006
    #3
  4. David Squire Guest

    wrote:
    > David Squire skrev:
    >
    >> wrote:
    >>> Hi all
    >>>
    >>> I have a apache running with mod_perl, it is set up with access-control
    >>> by a .htaccess-file with more than 1 user in it.
    >>>
    >>> I need to get the username from the one that have logged in. How do I
    >>> do that ?
    >>>

    >> It's a standard CGI environment variable: REMOTE_USER
    >>
    >> You get access to environment variables in Perl via the %ENV hash.
    >>
    >>
    >> DS

    >
    > For some resson REMOTE_USER i not in %ENV ?
    >


    It works for me. Note that it is only set for pages protected using
    ..htaccess files - which you say you are using.

    Please show us some code so that we have some chance of diagnosing your
    problem.


    DS
     
    David Squire, Aug 5, 2006
    #4
  5. Guest

    David Squire skrev:

    > wrote:
    > > David Squire skrev:
    > >
    > >> wrote:
    > >>> Hi all
    > >>>
    > >>> I have a apache running with mod_perl, it is set up with access-control
    > >>> by a .htaccess-file with more than 1 user in it.
    > >>>
    > >>> I need to get the username from the one that have logged in. How do I
    > >>> do that ?
    > >>>
    > >> It's a standard CGI environment variable: REMOTE_USER
    > >>
    > >> You get access to environment variables in Perl via the %ENV hash.
    > >>
    > >>
    > >> DS

    > >
    > > For some resson REMOTE_USER i not in %ENV ?
    > >

    >
    > It works for me. Note that it is only set for pages protected using
    > .htaccess files - which you say you are using.
    >
    > Please show us some code so that we have some chance of diagnosing your
    > problem.
    >
    >
    > DS


    # From my apache (one of the, got at apache running behind with
    mod_perl this apache rewrite to it)
    Maby this it the problem ?

    <VirtualHost *>
    ServerName somedomain.com

    <Location />
    AuthName MyDomain
    AuthType basic
    AuthUserFile /home/user/.htpasswd
    require valid-user
    </Location>

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^.*\.gif$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.jpeg$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.jpg$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.jpe$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.ico$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.css$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.html$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.htm$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.pdf$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.js$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.png$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.pl$ [NC]
    RewriteCond %{REQUEST_URI} !^.*\.txt$ [NC]
    RewriteRule ^(.*)$ http://127.0.0.1:8097$1 [P,NC]

    <Directory />
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
    </Directory>


    ServerAdmin
    DocumentRoot /home/user/html
    ErrorLog /home/user/log/error_log-admin
    CustomLog /home/user/log/access_log-admin common
    </VirtualHost>
     
    , Aug 5, 2006
    #5
  6. David Squire Guest

    wrote:
    > David Squire skrev:
    >
    >> wrote:
    >>> David Squire skrev:
    >>>
    >>>> wrote:
    >>>>> Hi all
    >>>>>
    >>>>> I have a apache running with mod_perl, it is set up with access-control
    >>>>> by a .htaccess-file with more than 1 user in it.
    >>>>>
    >>>>> I need to get the username from the one that have logged in. How do I
    >>>>> do that ?
    >>>>>
    >>>> It's a standard CGI environment variable: REMOTE_USER
    >>>>
    >>>> You get access to environment variables in Perl via the %ENV hash.
    >>>>
    >>> For some resson REMOTE_USER i not in %ENV ?
    >>>

    >> It works for me. Note that it is only set for pages protected using
    >> .htaccess files - which you say you are using.
    >>
    >> Please show us some code so that we have some chance of diagnosing your
    >> problem.
    >>

    > # From my apache (one of the, got at apache running behind with
    > mod_perl this apache rewrite to it)
    > Maby this it the problem ?
    >
    > <VirtualHost *>
    > ServerName somedomain.com


    [snip]

    Show us your *Perl* code.


    DS
     
    David Squire, Aug 5, 2006
    #6
  7. Guest

    skrev:

    > David Squire skrev:
    >
    > > wrote:
    > > > David Squire skrev:
    > > >
    > > >> wrote:
    > > >>> Hi all
    > > >>>
    > > >>> I have a apache running with mod_perl, it is set up with access-control
    > > >>> by a .htaccess-file with more than 1 user in it.
    > > >>>
    > > >>> I need to get the username from the one that have logged in. How do I
    > > >>> do that ?
    > > >>>
    > > >> It's a standard CGI environment variable: REMOTE_USER
    > > >>
    > > >> You get access to environment variables in Perl via the %ENV hash.
    > > >>
    > > >>
    > > >> DS
    > > >
    > > > For some resson REMOTE_USER i not in %ENV ?
    > > >

    > >
    > > It works for me. Note that it is only set for pages protected using
    > > .htaccess files - which you say you are using.
    > >
    > > Please show us some code so that we have some chance of diagnosing your
    > > problem.
    > >
    > >
    > > DS

    >
    > # From my apache (one of the, got at apache running behind with
    > mod_perl this apache rewrite to it)
    > Maby this it the problem ?
    >
    > <VirtualHost *>
    > ServerName somedomain.com
    >
    > <Location />
    > AuthName MyDomain
    > AuthType basic
    > AuthUserFile /home/user/.htpasswd
    > require valid-user
    > </Location>
    >
    > RewriteEngine On
    > RewriteCond %{REQUEST_URI} !^.*\.gif$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.jpeg$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.jpg$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.jpe$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.ico$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.css$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.html$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.htm$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.pdf$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.js$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.png$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.pl$ [NC]
    > RewriteCond %{REQUEST_URI} !^.*\.txt$ [NC]
    > RewriteRule ^(.*)$ http://127.0.0.1:8097$1 [P,NC]
    >
    > <Directory />
    > AllowOverride AuthConfig
    > Order allow,deny
    > Allow from all
    > </Directory>
    >
    >
    > ServerAdmin
    > DocumentRoot /home/user/html
    > ErrorLog /home/user/log/error_log-admin
    > CustomLog /home/user/log/access_log-admin common
    > </VirtualHost>


    I put my Auth-things in my second apache-conf, then i worked...

    Thanks for all your help
     
    , Aug 5, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stoco

    .htaccess and perl cgi

    Stoco, Jan 12, 2004, in forum: Perl
    Replies:
    0
    Views:
    2,872
    Stoco
    Jan 12, 2004
  2. Replies:
    1
    Views:
    585
    Michael Wojcik
    May 28, 2005
  3. Nospam
    Replies:
    3
    Views:
    615
    Jerry Stuckle
    May 27, 2006
  4. Nospam
    Replies:
    3
    Views:
    714
    David Dorward
    Aug 15, 2006
  5. The Poor
    Replies:
    2
    Views:
    236
    Gregory Toomey
    Sep 27, 2003
Loading...

Share This Page