Re: [users@httpd] Invoking PHP without .php extension?

2011-07-08 Thread Michael B Allen
On Fri, Jul 8, 2011 at 12:13 PM, Jeroen Geilman  wrote:
> On 2011-07-07 19:54, Michael B Allen wrote:
>>
>> I want a request like:
>>
>>   /base/path/to/target?foo=bar
>>
>> to invoke a particular PHP file for everything under /base.
>>
>> It seems the usual way (only way?) to do this is with something like:
>>
>>   AddHandler php5-script .php
>>   AddType text/html .php
>>   DirectoryIndex index.php
>>
>> and with directives like:
>>
>>   Alias /base /path/to/base/html
>>
>>   
>>     Options Indexes FollowSymLinks
>>     AllowOverride None
>>     Order allow,deny
>>     Allow from all
>>
>>     RewriteEngine on
>>     RewriteBase /base
>>     RewriteCond %{REQUEST_FILENAME} !-f
>>     RewriteCond %{REQUEST_FILENAME} !-d
>>     RewriteCond %{REQUEST_FILENAME} !-l
>>     RewriteRule .* index.php [L]
>>   
>>
>> However this is a disaster. The request for
>> /base/path/to/target?foo=bar is received inside the PHP script as
>> /base/index.php/path/to/target?foo=bar. Now the application has to
>> have intimate knowledge of the presence of the extra /index.php
>> segment and exclude it from URLs and paths emitted by the application.
>> The internal representation doesn't match the reality of the external
>> representation.
>>
>> So my question is, is there a way to directly invoke a preconfigured
>> PHP script for everything at / under a certain location without using
>> the .php extension in the request path?
>
> Alias /your/base/path /usr/share/your.php.file
>
> And set AcceptPathInfo.

That works. Near as I can tell this does precisely what was asked.

  Alias /base/images /path/to/base/html/images
  Alias /base/script /path/to/base/html/script
  Alias /base/css /path/to/base/html/css
  Alias /base /path/to/base/html/index.php

  
  AcceptPathInfo on
  

No mod_rewrite hackery.

Thanks,
Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] Invoking PHP without .php extension?

2011-07-07 Thread Michael B Allen
On Thu, Jul 7, 2011 at 9:35 PM, Devraj Mukherjee  wrote:
> On Fri, Jul 8, 2011 at 9:54 AM, Michael B Allen  wrote:
>> This is a wreck and I must say I don't think it has much to do with
>> PHP. It has to do with the CGI model which is all but dead.
>>
>
> Considered Python via mod_wsgi?

Until Python switches to using curly braces for code blocks instead of
indentation with tabs, it will not even be considered.

Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] Invoking PHP without .php extension?

2011-07-07 Thread Michael B Allen
On Thu, Jul 7, 2011 at 7:02 PM, Devraj Mukherjee  wrote:
> Hi,
>
> If your Rewrite rule reads something like this
>
> RewriteRule ^api/(.*) api-gateway.php   [L]
>
> Then basically you can extract the last few bit using regular
> expression in our case
>
> $urlParts = null;
> preg_match('/api\/([^\/]+)\/([0-9]+)*/', $_SERVER['REQUEST_URI'], $urlParts);
> $handlerName = count($urlParts) > 1 ? $urlParts[1] : null;
> $identifier = count($urlParts) > 2 ? $urlParts[2] : null;
>
> I would strongly suggest that you use Rewrite rules to achieve this.
> Allowing arbitary patterns to use the PHP parser could be an issue
> from a security standpoint.

So asking the admin to mod_rewrite the .php script into the URI and
then having the developer to reverse the rewrite rule within the
script is more secure? I don't think so.

This is a wreck and I must say I don't think it has much to do with
PHP. It has to do with the CGI model which is all but dead.

Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



[users@httpd] Invoking PHP without .php extension?

2011-07-07 Thread Michael B Allen
I want a request like:

  /base/path/to/target?foo=bar

to invoke a particular PHP file for everything under /base.

It seems the usual way (only way?) to do this is with something like:

  AddHandler php5-script .php
  AddType text/html .php
  DirectoryIndex index.php

and with directives like:

  Alias /base /path/to/base/html

  
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

RewriteEngine on
RewriteBase /base
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
  

However this is a disaster. The request for
/base/path/to/target?foo=bar is received inside the PHP script as
/base/index.php/path/to/target?foo=bar. Now the application has to
have intimate knowledge of the presence of the extra /index.php
segment and exclude it from URLs and paths emitted by the application.
The internal representation doesn't match the reality of the external
representation.

So my question is, is there a way to directly invoke a preconfigured
PHP script for everything at / under a certain location without using
the .php extension in the request path?

Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] Canonicalizing Domains / Hostnames

2011-07-06 Thread Michael B Allen
On Wed, Jul 6, 2011 at 10:23 PM, Michael B Allen  wrote:
> On Wed, Jul 6, 2011 at 10:05 PM, Sean Conner  wrote:
>> It was thus said that the Great Michael B Allen once stated:
>>>
>>> Hi Sean,
>>>
>>> Ok. But I already have:
>>>
>>> 
>>>   ServerName www.busicorp.com
>>>   ...
>>> 
>>>
>>> Can I have multiple VirtualHost sections with the same address (*:80)
>>> or expressions that overlap logically?
>>
>>  Yes.  You'll need to add a NameVirtualHost directive before the
>> VirtualHost directives.
>>
>> NameVirtualHost *:80
>>
>> 
>>  ServerName www.busicorp.com
>>  ...
>> 
>>
>> 
>>  ServerName server123.vps.hosting.net busicorp.com
>>  Redirect permanent    / http://www.busicorp.com/
>> 
>>
>>  The NameVirtualHost directive tells Apache that there multiple sites
>> sharing the same IP address.  Apache will then use the information the
>> browser passes in (as part of the request) to determine which site to
>> reference (it's the "Host:" header the browser sends in).  If it's missing,
>> Apache will default to the first VirtualHost listed (so you want your
>> primary listed first---unless I'm mistaken, which I could be).
>
> Thanks,
>
> This worked for redirecting busicorp.com to http://www.busicorp.com/.
> But it did not work for server123.vps.hosting.net (which strangely
> enough has a different IP address). Odd.

Nevermind. I have my servers mixed up. I had to tweak the config on
two separate servers.

I have it all working now (I think).

Thanks,
Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] Canonicalizing Domains / Hostnames

2011-07-06 Thread Michael B Allen
On Wed, Jul 6, 2011 at 10:05 PM, Sean Conner  wrote:
> It was thus said that the Great Michael B Allen once stated:
>>
>> Hi Sean,
>>
>> Ok. But I already have:
>>
>> 
>>   ServerName www.busicorp.com
>>   ...
>> 
>>
>> Can I have multiple VirtualHost sections with the same address (*:80)
>> or expressions that overlap logically?
>
>  Yes.  You'll need to add a NameVirtualHost directive before the
> VirtualHost directives.
>
> NameVirtualHost *:80
>
> 
>  ServerName www.busicorp.com
>  ...
> 
>
> 
>  ServerName server123.vps.hosting.net busicorp.com
>  Redirect permanent    / http://www.busicorp.com/
> 
>
>  The NameVirtualHost directive tells Apache that there multiple sites
> sharing the same IP address.  Apache will then use the information the
> browser passes in (as part of the request) to determine which site to
> reference (it's the "Host:" header the browser sends in).  If it's missing,
> Apache will default to the first VirtualHost listed (so you want your
> primary listed first---unless I'm mistaken, which I could be).

Thanks,

This worked for redirecting busicorp.com to http://www.busicorp.com/.
But it did not work for server123.vps.hosting.net (which strangely
enough has a different IP address). Odd.

Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] Canonicalizing Domains / Hostnames

2011-07-06 Thread Michael B Allen
On Wed, Jul 6, 2011 at 8:59 PM, Sean Conner  wrote:
> It was thus said that the Great Michael B Allen once stated:
>> Hi All,
>>
>> I have a site that is accessible through multiple hostnames like:
>>
>>   http://www.busicorp.com/
>>   http://server123.vps.hosting.net/
>>   http://busicorp.com/
>>
>> but I only want the site to be accessible through the first hostname
>> (http://www.busicorp.com/ and https://www.busicorp.com/). How can I
>> block these other hostnames? I have been using Apache for many years
>> but I'm drawing a blank as to where to begin with this. Can someone
>> give me a pointer?
>
>  The easiest might be to set the non-preferred domains to redirect to the
> preferred domain.  Something like:
>
> 
>  ServerName    server123.vps.hosting.net busicorp.com
>  Redirect      permanent       /       http://www.busicorp.com/
> 
>
>  That will redirect all requests to server123.vps.hosting.net and
> busicorp.com to your preferred domain name, and at least as far as Google
> goes, the Page Rank for the non-preferred sites will be transferred to the
> preferred domain name.

Hi Sean,

Ok. But I already have:


  ServerName www.busicorp.com
  ...


Can I have multiple VirtualHost sections with the same address (*:80)
or expressions that overlap logically?

Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



[users@httpd] Canonicalizing Domains / Hostnames

2011-07-06 Thread Michael B Allen
Hi All,

I have a site that is accessible through multiple hostnames like:

  http://www.busicorp.com/
  http://server123.vps.hosting.net/
  http://busicorp.com/

but I only want the site to be accessible through the first hostname
(http://www.busicorp.com/ and https://www.busicorp.com/). How can I
block these other hostnames? I have been using Apache for many years
but I'm drawing a blank as to where to begin with this. Can someone
give me a pointer?

Thanks,
Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



[EMAIL PROTECTED] Strange Timezone Switching Between GMT and US\Eastern in Module

2008-02-08 Thread Michael B Allen
I have an Apache module that uses localtime(3) to generate timestamps
for logging. When the module is running and executed by worker
processes these timestamps are correctly US\Eastern time. However,
when the module is initializing and deinitializing as the root
process, the timestamps are in GMT time.

Or rather I have a customer with a log showing this. I have not been
able to reproduce the problem outside of calling setenv("TZ", "GMT",
1); tzset();.

I would suspect that /etc/localtime was wrong but if that were the
case the timestamps would be wrong all the time no?

Anyone have an idea as to what might be happening?

Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [EMAIL PROTECTED] simple mod_rewrite question

2007-08-06 Thread Michael B Allen
On 8/6/07, Joshua Slive <[EMAIL PROTECTED]> wrote:
> On 8/5/07, Michael B Allen <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a very simple mod_rewrite requirement but I can't seem to make it 
> > work.
> >
> > I want all paths to invoke a php script *except* some that begin with
> > certain directories. For example, consider the following URLs:
> >
> > http://www.example.com/z/blog/07/10
> > http://www.example.com/z/css/style.css
> >
> > I want the first to execute the PHP script. But if the request path
> > begins with /z/css/ then I want the PHP script to NOT be executed such
> > that css/style.css is retrieved as if there had been no RewriteRule at
> > all.
> >
> > I tried the following:
> >
> > Alias /z/ /home/miallen/p/z/www/
> > 
> >RewriteEngine On
> >RewriteBase /z
> >RewriteRule ^/css/(.*) css/$1 [L]
> >RewriteRule ^/* index.php
> >Order allow,deny
> >Allow from all
> >Options Indexes FollowSymLinks
> > 
> >
> > The second RewriteRule works and I have seen the first rule work if I
> > don't prefix it's expression with ^/ but they do not work together.
>
> This first thing is to put the rewrite stuff in the main server
> context instead of inside a  section:
> RewriteRule ^/z/css - [L]
> RewriteRule ^/z.* /home/miallen/p/z/www/index.php

Hi Joshua,

That works great.

Thanks,
Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[EMAIL PROTECTED] simple mod_rewrite question

2007-08-05 Thread Michael B Allen
Hi,

I have a very simple mod_rewrite requirement but I can't seem to make it work.

I want all paths to invoke a php script *except* some that begin with
certain directories. For example, consider the following URLs:

http://www.example.com/z/blog/07/10
http://www.example.com/z/css/style.css

I want the first to execute the PHP script. But if the request path
begins with /z/css/ then I want the PHP script to NOT be executed such
that css/style.css is retrieved as if there had been no RewriteRule at
all.

I tried the following:

Alias /z/ /home/miallen/p/z/www/

   RewriteEngine On
   RewriteBase /z
   RewriteRule ^/css/(.*) css/$1 [L]
   RewriteRule ^/* index.php
   Order allow,deny
   Allow from all
   Options Indexes FollowSymLinks


The second RewriteRule works and I have seen the first rule work if I
don't prefix it's expression with ^/ but they do not work together.

Can someone give me a clue?

Mike

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[EMAIL PROTECTED] Setting Default LC_LANG

2007-03-24 Thread Michael B Allen
I can set LANG=en_US.UTF-8 in /etc/init.d/apache on a Ubuntu system,
PHP's setlocale echos it and i18n text is handled properly.

However, if I do [EMAIL PROTECTED] or LANG=de_DE.UTF-8 setlocale
returns nothing and there is no error reported in Apache's log.

If I run:

  # locale -a
  C
  en_US.utf8
  POSIX

This suggests to me that I simply do not have the right locate data. Do
I need to install locale files? The language-support-de package on Ubuntu
looks promising but I'm not sure. Any ideas?

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]