NYCPHP Meetup

NYPHP.org

[nycphp-talk] Howto create custom URLs

Ben Sgro (ProjectSkyline) ben at projectskyline.com
Mon Mar 19 14:11:44 EDT 2007


Hey Rob,

So I decided to do what you mentioned:

$eventNameStr = strrchr($_SERVER['REQUEST_URI'], "/");
$eventNameStr = substr($eventNameStr, 1, strlen($eventNameStr));
error_log($eventNameStr); <-- this is the other line of the error log snip 
below

However, I'm getting some wierd script action..

Here's a snippet from my error_log( ) calls when loading: 
http://192.168.1.102/pc_release/index.php/26657d5ff9020d2abefe558796b99584

[19-Mar-2007 13:53:08] 26657d5ff9020d2abefe558796b99584
[19-Mar-2007 13:53:08] DBAS: 192.168.1.106 connected to mysql server db 
'hhc'
[19-Mar-2007 13:53:08] style.css
[19-Mar-2007 13:53:08] DBAS: 192.168.1.106 connected to mysql server db 
'hhc'
[19-Mar-2007 13:53:08] favicon.ico
[19-Mar-2007 13:53:08] DBAS: 192.168.1.106 connected to mysql server db 
'hhc'
[19-Mar-2007 13:53:08] pc_app_logo.png
[19-Mar-2007 13:53:08] DBAS: 192.168.1.106 connected to mysql server db 
'hhc'
[19-Mar-2007 13:53:08] favicon.ico
[19-Mar-2007 13:53:08] DBAS: 192.168.1.106 connected to mysql server db 
'hhc'

As you can see, its loading the file (index.php) 5 times for a single 
request. (the hash, style, favion, png and favicon)..

Now, when loading:
http://192.168.1.102/pc_release/index.php?act=700&eventid=26657d5ff9020d2abefe558796b99584

[19-Mar-2007 13:54:09] 
index.php?act=700&eventid=26657d5ff9020d2abefe558796b99584
[19-Mar-2007 13:54:09] DBAS: 192.168.1.106 connected to mysql server db 
'hhc'

So, any ideas as to why its working like this?

- Ben


----- Original Message ----- 
From: "Rob Marscher" <rmarscher at beaffinitive.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Monday, March 19, 2007 11:06 AM
Subject: Re: [nycphp-talk] Howto create custom URLs


> On Mar 19, 2007, at 10:46 AM, Donald J Organ IV wrote:
>
>> P.S.   mod_rewrite is usually enabled or can be enabled on any  simple 
>> hosting plan that is using apache, if you encounter a host  that uses 
>> apache and wont turn it on, i would suggest finding  another host.
>
> Also, you can usually put mod_rewrite rules in a .htaccess file -- so  it 
> doesn't require httpd.conf access.
>
> Even without mod_rewrite, you could still do myhost.com/index.php/ 
> MayEvent07 -- you then look at $_SERVER['REQUEST_URI'], remove  index.php/ 
> from it, and then explode on / to get your args.
>
> Even if you are able to use mod_rewrite, you probably need to do a 
> database lookup to find MayEvent07 so your mod_rewrite rule would be 
> something like this:
>
> RewriteEngine on
> RewriteRule !\.(js|ico|gif|jpg|png|css|html|htm|xml|php)$ index.php
>
> Then you still process it by exploding $_SERVER['REQUEST_URI'] but  you 
> won't have index.php in that string.  The rewrite rule forwards 
> everything to index.php except for files with the extensions listed.
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php 




More information about the talk mailing list