Rewrites for the PHP,Standalone OpenID Server

Niels Berkers niels at quotar.com
Wed Apr 25 11:34:00 PDT 2007


an other solution ( of course u need the correct DNS records in place )



httpd.conf
=====================
<VirtualHost 83.160.179.6:80>
    ServerName names.openid.quotar.com
    ServerAlias *.openid.quotar.com 	#<-----catch all
    DocumentRoot /var/www/quotar.com/openid/names
    <Directory /var/www/quotar.com/openid/names/>
       AllowOverride None
       Order Deny,Allow
       Allow from all
    </Directory>
    ErrorLog /var/log/httpd/names-quotar.com.error_log
    CustomLog /var/log/httpd/names-quotar.com.access_log common
</VirtualHost>

<VirtualHost 83.160.179.6:80>
    ServerName openid.quotar.com
    DocumentRoot /var/www/quotar.com/openid/PHP-server-1.1/src/
    <Directory /var/www/quotar.com/openid/PHP-server-1.1/src/>
       AllowOverride None
       Order Deny,Allow
       Allow from all
    </Directory>
    ErrorLog /var/log/httpd/openid-quotar.com.error_log
    CustomLog /var/log/httpd/openid-quotar.com.access_log common
</VirtualHost>


/var/www/quotar.com/openid/names/index.php
=========================
<?php
 
preg_match("/(\w+).openid.quotar.com/",$_SERVER["SERVER_NAME"],$aMatch);

?>
<html>
   <head>
     <link rel="openid.server" 
href="http://openid.quotar.com/index.php/serve">
     <link rel="openid.delegate" href="http://<?php echo $aMatch[1]; 
?>.openid.quotar.com/">
   </head>
   <body>
     <h3>OpenID Identity Page</h3>

     <p>This is the identity page for the user <strong><?php echo 
$aMatch[1]; ?></strong>.
     </p>
   </body>
</html>

br,


Niels







Supercharged wrote:
> You have your .htaccess located at host http://my_server, but
> http://my_user.my_server is completely different host, so your
> .htaccess does not matter at all.
> 
> What you should do, is to make all http://*.my_server subdomains to
> redirect to http://my_server.
> 
> You should go to your DNS settings and add a DNS-alias. And probably
> add ServerAlias to your Apache configuration. Try googling for
> 'virtual subdomain dns' or something like that.
> 
> On 4/25/07, Antonio Martinez Martinez <amm03 at tid.es> wrote:
>>       Hi all,
>>
>>  First of all, thanks a lot to the webmaster for his/her support. But I'm
>> still in troubles,  :-(
>>
>>  I'm using a consumer I found here.
>>
>>  It's a php class that uses CURL. Concretely, the function that makes the
>> CURL request is:
>>
>>  function CURL_Request($url, $method="GET", $params = "") { // Remember, SSL
>> MUST BE SUPPORTED
>>              if (is_array($params)) $params = $this->array2url($params);
>>
>>              $curl = curl_init($url . ($method == "GET" && $params != "" ?
>> "?" . $params : ""));  //SEE BELOW
>>              curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
>>              curl_setopt($curl, CURLOPT_HEADER, true);
>>              curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
>>              curl_setopt($curl, CURLOPT_HTTPGET, ($method == "GET"));
>>              curl_setopt($curl, CURLOPT_POST, ($method == "POST"));
>>              if ($method == "POST") curl_setopt($curl, CURLOPT_POSTFIELDS,
>> $params);
>>              curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
>>
>>              $response = curl_exec($curl);   //execute the curl specified
>> session by $curl
>>
>>              if (curl_errno($curl) == 0){
>>                  $response;
>>              }else{
>>                  $this->ErrorStore('OPENID_CURL', curl_error($curl));
>>              }
>>
>>              return $response;
>>      }
>>
>>  In line 2, if I use an openid identifier such "my_user.my_server", the $url
>> value is "http://my_user.my_server", that obviously doesn't exist. So, the
>> proposed solution in
>>
>> http://www.sysadm.org/blog/servidor-miopenid-identificacion-con-nombre-de-host-estilo-nombremiopenides/
>>
>>
>>  is to add 4 lines in .htaccess file. I've added these lines this way:
>>
>>
>> RewriteEngine on
>> RewriteCond %{HTTP_HOST}            !^my_server$
>> RewriteCond %{QUERY_STRING}         !^user=.+$
>> RewriteCond %{HTTP_HOST}            ^(.+)\.my_server$
>> RewriteRule (.*)                    /?user=%1               [NC,L]
>>
>>
>>  I think that .htaccess file should transform "my_user.my_server"  into
>> "http://my_server/?user=my_user", but this doesn't happen.
>>
>>  I'm not sure if I'm wrong in .htaccess file or due to CURL use, this
>> doesn't work correctly.
>>
>>  Could you give me a hand, please?
>>
>>  Thanks a lot in advance for your attention and patience.
>>
>>  Cheers,
>>
>>
>>
>> --
>>
>>
>>
>>
>>  Antonio Martínez Martínez
>>
>>
>>
>>
>>
>>
>>
>>
> _______________________________________________
> Dev mailing list
> Dev at lists.openidenabled.com
> http://lists.openidenabled.com/mailman/listinfo/dev




More information about the Dev mailing list