Re: [PHP] URL Rewriting

2013-06-02 Thread Daniel Brown
Studying archaeology now, Tam?  ;-P


On Sat, Jun 1, 2013 at 8:22 PM, Tamara Temple tamouse.li...@gmail.com wrote:
 Silvio Siefke li...@silvio-siefke.de wrote:
 On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote:
   Has someone a Link with Tutorials or other Information?
 
  Not entirely sure what you're asking here, or how you (or the
  nginx folks) expect it to relate to PHP.  Do you mean that you want to
  use PHP to have theme2.php act as if it was called as theme.php?id=2 ?

 I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2
 through 16 at moment. And for google and other Search  Engines not good the
 links, better where i can rewrite to a fix link, and when someone use the
 link, php write to correct url.

 Common SEO mythology is that you need pretty human-understandable
 links. (In point of fact, the search engines care not in the least.)
 However, human-understandable URLs are a benefit to users when they want
 to understand what they're linking to or clicking on.

 A human-understandable link is more like:

 http://www.example.com/blog/2013-05-a-day-in-the-life-of-my-dog

 not:

 http://www.example.com/blog/2

 as that really does not provide any more information than:

 http://www.example.com/blog.php?id=2

 Otherwise, Daniel's solution below should do the trick.

 Sorry my english not perfect on earth.


  If so, it's not redirect or rewrite, and it's extremely hacky, but
  this is the only real way PHP could achieve the desired result:
 
  ?php
  // dynamictheme.php
 
  if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) {
$_GET['id'] = $match[1];
include dirname(__FILE__).'/theme.php';
  }
 
  ?
 
  Then just symlink dynamictheme.php to your various themes like so:
 
  ln -s dynamictheme.php theme2.php
  ln -s dynamictheme.php theme301.php
  ln -s dynamictheme.php theme18447.php
 







 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




--
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL Rewriting

2013-06-02 Thread Tamara Temple
Daniel Brown danbr...@php.net wrote:
 Studying archaeology now, Tam?  ;-P

Always been a huge fan. :)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL Rewriting

2013-06-01 Thread Tamara Temple
Silvio Siefke li...@silvio-siefke.de wrote:
 On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote:
   Has someone a Link with Tutorials or other Information?
  
  Not entirely sure what you're asking here, or how you (or the
  nginx folks) expect it to relate to PHP.  Do you mean that you want to
  use PHP to have theme2.php act as if it was called as theme.php?id=2 ?
 
 I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2
 through 16 at moment. And for google and other Search  Engines not good the
 links, better where i can rewrite to a fix link, and when someone use the
 link, php write to correct url. 

Common SEO mythology is that you need pretty human-understandable
links. (In point of fact, the search engines care not in the least.)
However, human-understandable URLs are a benefit to users when they want
to understand what they're linking to or clicking on.

A human-understandable link is more like:

http://www.example.com/blog/2013-05-a-day-in-the-life-of-my-dog

not:

http://www.example.com/blog/2

as that really does not provide any more information than:

http://www.example.com/blog.php?id=2

Otherwise, Daniel's solution below should do the trick.

 Sorry my english not perfect on earth. 
 
  
  If so, it's not redirect or rewrite, and it's extremely hacky, but
  this is the only real way PHP could achieve the desired result:
  
  ?php
  // dynamictheme.php
  
  if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) {
$_GET['id'] = $match[1];
include dirname(__FILE__).'/theme.php';
  }
  
  ?
  
  Then just symlink dynamictheme.php to your various themes like so:
  
  ln -s dynamictheme.php theme2.php
  ln -s dynamictheme.php theme301.php
  ln -s dynamictheme.php theme18447.php
  







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL Rewriting

2011-06-23 Thread Ashley Sheridan


Silvio Siefke li...@silvio-siefke.de wrote:

On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote:
  Has someone a Link with Tutorials or other Information?

 Not entirely sure what you're asking here, or how you (or the
 nginx folks) expect it to relate to PHP.  Do you mean that you want
to
 use PHP to have theme2.php act as if it was called as theme.php?id=2
?

I have me write a blog, but my blog has link like blogdetail.html?id=1
or =2
through 16 at moment. And for google and other Search  Engines not good
the
links, better where i can rewrite to a fix link, and when someone use
the
link, php write to correct url.

Sorry my english not perfect on earth.

I've not yet seen any evidence yet that pretty URLs actually benefit SEO. I 
regularly search for answers to problems online, and mostly I get forums as the 
results, all of which have URLs like showthread.php?t=1234567

I see that url rewriting is always suggested on SEO checklists, but with no 
evidence. The best evidence I could find was out of date by about a decade, so 
not that useful here and today.

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL Rewriting

2011-06-22 Thread Fatih P.
try

RewriteEngine on
RewriteRule ^theme([0-9]+).php$  /index.php?theme=$1 [L]






On Wed, Jun 22, 2011 at 11:22 PM, Silvio Siefke li...@silvio-siefke.dewrote:

 Hello,

 is there a chance with php to use rewriting?

 Like Example:

 mysite.com/theme.php?id=1 to theme.php theme2.php etc.

 I have ask on the nginx list, but there they say i should use the power
 language php.

 When i search in google for Examples or Tutorials i only found
 mod_rewriting.


 Has someone a Link with Tutorials or other Information?

 Thank you.

 Nice Day.

 Silvio

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] URL Rewriting

2011-06-22 Thread Daniel Brown
On Wed, Jun 22, 2011 at 17:32, Fatih P. fatihpirist...@gmail.com wrote:
 try

 RewriteEngine on
 RewriteRule ^theme([0-9]+).php$  /index.php?theme=$1 [L]

That's neither nginx nor PHP, so it's not really relevant to the
OP's questions.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL Rewriting

2011-06-22 Thread Daniel P. Brown
On Wed, Jun 22, 2011 at 17:22, Silvio Siefke li...@silvio-siefke.de wrote:
 Hello,

 is there a chance with php to use rewriting?

 Like Example:

 mysite.com/theme.php?id=1 to theme.php theme2.php etc.

 I have ask on the nginx list, but there they say i should use the power
 language php.

 When i search in google for Examples or Tutorials i only found mod_rewriting.


 Has someone a Link with Tutorials or other Information?

Not entirely sure what you're asking here, or how you (or the
nginx folks) expect it to relate to PHP.  Do you mean that you want to
use PHP to have theme2.php act as if it was called as theme.php?id=2 ?

If so, it's not redirect or rewrite, and it's extremely hacky, but
this is the only real way PHP could achieve the desired result:

?php
// dynamictheme.php

if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) {
  $_GET['id'] = $match[1];
  include dirname(__FILE__).'/theme.php';
}

?

Then just symlink dynamictheme.php to your various themes like so:

ln -s dynamictheme.php theme2.php
ln -s dynamictheme.php theme301.php
ln -s dynamictheme.php theme18447.php

-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL Rewriting

2011-06-22 Thread Silvio Siefke
On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote:
  Has someone a Link with Tutorials or other Information?
 
 Not entirely sure what you're asking here, or how you (or the
 nginx folks) expect it to relate to PHP.  Do you mean that you want to
 use PHP to have theme2.php act as if it was called as theme.php?id=2 ?

I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2
through 16 at moment. And for google and other Search  Engines not good the
links, better where i can rewrite to a fix link, and when someone use the
link, php write to correct url. 

Sorry my english not perfect on earth. 

 
 If so, it's not redirect or rewrite, and it's extremely hacky, but
 this is the only real way PHP could achieve the desired result:
 
 ?php
 // dynamictheme.php
 
 if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) {
   $_GET['id'] = $match[1];
   include dirname(__FILE__).'/theme.php';
 }
 
 ?
 
 Then just symlink dynamictheme.php to your various themes like so:
 
 ln -s dynamictheme.php theme2.php
 ln -s dynamictheme.php theme301.php
 ln -s dynamictheme.php theme18447.php
 


Regards 
Silvio

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL Rewriting

2011-06-22 Thread Silvio Siefke
On Wed, 22 Jun 2011 23:32:10 +0200 Fatih P. wrote:
 try
 
 RewriteEngine on
 RewriteRule ^theme([0-9]+).php$  /index.php?theme=$1 [L]

That is rule for Apache i think. I have nginx, and there i have try much
rules but nothing want work. And on the list from nginx the maintainer write,
i should use the power language php. 


Regards
Silvio

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-15 Thread Peter Vertes




I had the same problem with PHP after I've upgraded to 4.3.3 from 4.3.1. I was tearing my hair out but couldn't figure out what was wrong. I ended up editing my php.ini file and turning REGISTER GLOBALS = On. It works fine now and since this is on my development box I don't really care about security that much. Hope this helped...

-Pete

P.S.: This all happened on a Gentoo Linux box...

On Wed, 2004-01-14 at 17:11, Ryan A wrote:

Oops sorry, missed that.

Heres whats on top of the page:

echo Ok,we are in show.phpbr;
if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
\$_GET[id]br;}
if(isset($_GET[sid])){echo Got \$_GET[sid]br;}else{echo No
\$_GET[sid]br;}
print_r($_GET);
print_r($_GET['id']);
print_r($_GET['sid']);

and heres the output:

Ok,we are in show.php
No $_GET[id]
No $_GET[sid]
Array ( )


Ideas?

Cheers,
-Ryan




On 1/14/2004 10:56:35 PM, Jason Wong ([EMAIL PROTECTED]) wrote:
 On Thursday 15 January 2004 05:01, Ryan A wrote:

  I put this in for testing:
 
  if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo
 No
  \$_GET[id]br;}
  if(isset($_GET[sid])){echo Got \$_GET[sid]br;}else{echo
 No
  \$_GET[sid]br;}
 
  and heres the output:
  No $_GET[id]
  No $_GET[sid]
 
  So the variables are not being passed
  Any idea why and what I can do about this?
  (Am a total newbie here)

 As was previously suggested just do a

 print_r($_GET)

 to see what, if anything,
 you're getting.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Price's
 Advice:
 It's all a game -- play it to have fun.
 */

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
perl -e 'print pack(H*, 70766572746573406E79632E72722E636F6D0A)'








signature.asc
Description: This is a digitally signed message part


Re: [PHP] URL rewriting...anybody done this?

2004-01-15 Thread Ryan A
Hey,
Thanks for replying.

Globals are on heres my phpinfo page:
http://cheap-php-web-hosting.com/phpinfo.php

this is my .htaccess file:

RewriteEngine On
Options +FollowSymlinks
RewriteRule ^tt/(.*).php tt.php?id=$1

This is my php page:
?php
echo Ok,we are in tt.phpbr;
if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
\$_GET[id]br;}
print_r($_GET);
print_r($_REQUEST);
print_r($_GET['id']);
?

heres from where i am calling it:
http://cheap-php-web-hosting.com/tt/23


DAMN thing does not work.

Any ideas?

-Ryan





and heres how I am calling it
On 1/16/2004 12:55:22 AM, Peter Vertes ([EMAIL PROTECTED]) wrote:
 I had the same problem with PHP after
 I've upgraded to 4.3.3 from 4.3.1. I was tearing my hair out but couldn't
 figure out what was wrong. I ended up editing my php.ini file and turning
 REGISTER GLOBALS = On. It works fine now and since this is on my
 development box I
 don't really care about security that much. Hope this helped...

 -Pete

 P.S.: This all happened on a Gentoo Linux box...

 On Wed, 2004-01-14 at 17:11, Ryan A wrote: Oops sorry, missed that. Heres
whats on top of the page: echo Ok,we are in show.phpbr;
if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
\$_GET[id]br;} if(isset($_GET[sid])){echo Got
\$_GET[sid]br;}else{echo No \$_GET[sid]br;} print_r($_GET);
print_r($_GET['id']); print_r($_GET['sid']); and heres the output: Ok,we are
in show.php No $_GET[id] No $_GET[sid] Array ( ) Ideas? Cheers, -Ryan On
1/14/2004 10:56:35 PM, Jason Wong ([EMAIL PROTECTED]) wrote:  On
Thursday 15 January 2004 05:01, Ryan A wrote:I put this in for
testing: if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo
 No   \$_GET[id]br;}   if(isset($_GET[sid])){echo Got
\$_GET[sid]br;}else{echo  No   \$_GET[sid]br

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-15 Thread Justin French
On Friday, January 16, 2004, at 11:04  AM, Ryan A wrote:

RewriteEngine On
Options +FollowSymlinks
RewriteRule ^tt/(.*).php tt.php?id=$1
This is my php page:
?php
echo Ok,we are in tt.phpbr;
if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
\$_GET[id]br;}
print_r($_GET);
print_r($_REQUEST);
print_r($_GET['id']);
?
Ryan,

This would have been solved a lot quicker on a list dedicated to Apache.

I tested this, and it works:

.htaccess
---
#Options +FollowSymlinks
IfModule mod_rewrite.c
RewriteEngine On
RewriteRule ^tt.php/(.*) tt.php?id=$1
RewriteRule ^tt.php/(.*).php tt.php?id=$1
/IfModule
---
With this tt.php file:
---
h1tt.php/h1
pre
?
print_r($_GET);
?
/pre
---
A few notes:

- I commented out the Options line because *my* Apache set-up doesn't 
need it, but yours may (it depends on the httpd.conf file).

- I've tested the above with the following URLs:
- http://indentclients.com/tests/ryan/tt/45.php
- http://indentclients.com/tests/ryan/tt/45
- http://indentclients.com/tests/ryan/tt/45/
- http://indentclients.com/tests/ryan/tt.php/45.php
- http://indentclients.com/tests/ryan/tt.php/45
- http://indentclients.com/tests/ryan/tt.php/45/
In all cases, it output:
Array
(
[id] = 45
)
- it also works for me without the IfModule... and /IfModule lines

- if this STILL doesn't work, it's more than likely that your host does 
not allow mod_rewrite, doesn't allow you total freedom in your 
.htaccess file, etc etc -- find a new host.

Justin French

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] URL rewriting...anybody done this?

2004-01-15 Thread Ryan A
Hey Justin,

Ok,
 tried this with differient tests and directives for the past 2 days,
on 3 differient servers,
on 5 differient domains.
I updated the directives more times than I care to remember and restarted
apache so many times
I dont think it knows if its coming or goingbut you sir...are a f*g
genius coz the sob after
hours of frustration spanning 2 days.is working!

I just copied everything you wrote exactly and pasted themthen hit the
url on 3 differient servers...
and all 3 are giving me results...

Looks like the list has a new problem solver...watch out (Cpt) John Holmes!
:-D

Cheers,
-Ryan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Brad Pauly
On Wed, 2004-01-14 at 11:14, Ryan A wrote:
 Hi,
 I have a blog kind of app running on my site...presently it shows like this:
 show.php?category=Beginners%20Cornersid=1id=1
 
 After searching on google on how to make my blog my search engine friendly I
 came accorss
 mod_rewrite and couple of tutorials on it, finally the one I understood and
 tried to use was this one:
 
 http://www.phpfreaks.com/tutorials/23/0.php
 
 so I added this to my .htaccess:
 RewriteEngine On
 RewriteRule ^show/(.*)/(.*)/(.*).php
 /show.php?category=Beginners%20Cornersid=$2id=$3
 
 and added this to my httpd.conf:
 AccessFileName .htaccess
 Files ~ ^\.ht
 AllowOverride all
 Order allow,deny
 Deny from all
 Satisfy All
 /Files
 
 Directory /usr/local/www/rizkhan.net/www/articles
 Options ExecCGI FollowSymLinks Includes MultiViews
 AllowOverride all
 /Directory
 
 But somehow its not working :-(( I made the changes in the httpd.conf and
 also in a .htaccess file...

How isn't it working? What happens? I would try one variable first, get
that working, then add the others. Also, I am not sure how it will
handle the space in Beginners Corner. Try passing simple values first.

I am assuming you have Apache compiled with mod_rewrite and you have the
proper settings in httpd.conf (ie. LoadModule). Did you restart Apache?

- Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Hey,
Thanks for replying.

It seems to be partly working.

/*
How isn't it working? What happens? I would try one variable first, get
that working, then add the others. Also, I am not sure how it will
handle the space in Beginners Corner. Try passing simple values first.
*/
Its a bit hard to explain what happens so see for yourself:
Heres the index page:
http://www.rizkhan.net/articles/articles.php
Heres the actual page:
http://www.rizkhan.net/articles/show.php?category=Beginners%20Cornersid=1id=1
and then if you modify it to:
http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1

it just shows me the index...which even links wrong.

Ok, will try to pass a value without the space in between.


/*
I am assuming you have Apache compiled with mod_rewrite and you have the
proper settings in httpd.conf (ie. LoadModule). Did you restart Apache?
*/

Yep, mod_rewrite is installed (http://rizkhan.net/phpinfo.php)
I did restart apache.

Any ideas?

-Ryan



On 1/14/2004 7:34:56 PM, Brad Pauly ([EMAIL PROTECTED]) wrote:
 On Wed, 2004-01-14 at 11:14, Ryan A wrote:
  Hi,
  I have a blog kind of app running on my site...presently it shows like
 this:
  show.php?category=Beginners%20Cornersid=1id=1
 
  After searching on google on how to make my blog my search engine
 friendly I
  came accorss
  mod_rewrite and couple of tutorials on it, finally the one I understood
 and
  tried to use was this one:
 
  http://www.phpfreaks.com/tutorials/23/0.php
 
  so I added this to my .htaccess:
  RewriteEngine On
  RewriteRule ^show/(.*)/(.*)/(.*).php
  /show.php?category=Beginners%20Cornersid=$2id=$3
 
  and added this to my httpd.conf:
  AccessFileName .htaccess
  Files ~ ^\.ht
  AllowOverride all
  Order allow,deny
  Deny from all
  Satisfy All
  /Files
 
  Directory /usr/local/www/rizkhan.net/www/articles
  Options ExecCGI FollowSymLinks Includes MultiViews
  AllowOverride all
  /Directory
 
  But somehow its not working :-(( I made the changes in the httpd.conf
 and
  also in a .htaccess file...

 How isn't it working? What

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Jason Wong
On Thursday 15 January 2004 02:44, Ryan A wrote:

 It seems to be partly working.

 /*
 How isn't it working? What happens? I would try one variable first, get
 that working, then add the others. Also, I am not sure how it will
 handle the space in Beginners Corner. Try passing simple values first.
 */
 Its a bit hard to explain what happens so see for yourself:
 Heres the index page:
 http://www.rizkhan.net/articles/articles.php
 Heres the actual page:
 http://www.rizkhan.net/articles/show.php?category=Beginners%20Cornersid=1;
id=1 and then if you modify it to:
 http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1

 it just shows me the index...which even links wrong.

 Ok, will try to pass a value without the space in between.

   RewriteRule ^show/(.*)/(.*)/(.*).php
   /show.php?category=Beginners%20Cornersid=$2id=$3

It doesn't look like your rule would match. Try:
  RewriteRule ^show/(.*)/(.*)/(.*)

Another way to achieve a similar result without using Rewrite is to parse 
$_SERVER['REQUEST_URI'], and possibly $_SERVER['PATH_INFO']

Eg if your link is:

  http://www.rizkhan.net/articles/show.php/Beginners%20Corner/1/1

Then $_SERVER['REQUEST_URI'] would contain

  /articles/show.php/Beginners%20Corner/1/1

and $_SERVER['PATH_INFO'] would contain

  /Beginners%20Corner/1/1

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
You'd like to do it instantaneously, but that's too slow.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Brad Pauly
On Wed, 2004-01-14 at 11:44, Ryan A wrote:

[snip]

 Its a bit hard to explain what happens so see for yourself:
 Heres the index page:
 http://www.rizkhan.net/articles/articles.php
 Heres the actual page:
 http://www.rizkhan.net/articles/show.php?category=Beginners%20Cornersid=1id=1
 and then if you modify it to:
 http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1

[snip]

 Any ideas?

One thing I noticed is that your rule is looking for a .php at the end
so the above url will not match.

RewriteEngine On
RewriteRule ^show/(.*)/(.*)/(.*).php
/show.php?category=Beginners%20Cornersid=$2id=$3

I don't remember for sure, but do you need an [L] at the end of the
second line?

- Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Lowell Allen
 On Thursday 15 January 2004 02:44, Ryan A wrote:
 
 It seems to be partly working.
 
 /*
 How isn't it working? What happens? I would try one variable first, get
 that working, then add the others. Also, I am not sure how it will
 handle the space in Beginners Corner. Try passing simple values first.
 */
 Its a bit hard to explain what happens so see for yourself:
 Heres the index page:
 http://www.rizkhan.net/articles/articles.php
 Heres the actual page:
 http://www.rizkhan.net/articles/show.php?category=Beginners%20Cornersid=1;
 id=1 and then if you modify it to:
 http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1
 
 it just shows me the index...which even links wrong.
 
 Ok, will try to pass a value without the space in between.
 
 RewriteRule ^show/(.*)/(.*)/(.*).php
 /show.php?category=Beginners%20Cornersid=$2id=$3
 
 It doesn't look like your rule would match. Try:
 RewriteRule ^show/(.*)/(.*)/(.*)
 
 Another way to achieve a similar result without using Rewrite is to parse
 $_SERVER['REQUEST_URI'], and possibly $_SERVER['PATH_INFO']
 
 Eg if your link is:
 
 http://www.rizkhan.net/articles/show.php/Beginners%20Corner/1/1
 
 Then $_SERVER['REQUEST_URI'] would contain
 
 /articles/show.php/Beginners%20Corner/1/1
 
 and $_SERVER['PATH_INFO'] would contain
 
 /Beginners%20Corner/1/1

Ryan,

I'm doing what I believe Jason is indicating above. I'm sure in your
research you read the articles about URL rewriting on A List Apart,
specifically this one: http://www.alistapart.com/articles/succeed/. Using
a similar approach, I'm saving page content in a database with the unique
identifier set to the desired value of $REQUEST_URI. After redirecting all
requests to index.php as described in the article, I use code in index.php
similar to what's in the article, plus this for the database content:

-

// check for database content
$conn = db_connect();
if (!$conn) {
$db_error = mysql_error();
include(error_page.php);
exit();
}
// get the page details from db
$request = substr($REQUEST_URI, 1);
$results = mysql_query(SELECT DisplayStatus FROM Pages WHERE
MenuPath='$request' AND DisplayStatus='Y');
if (!$results) {
$db_error = mysql_error();
include(error_page.php);
exit();
}
if (mysql_num_rows($results)  0) {
include(page.php);
exit();
}

// if request has not been matched, include custom error page
include(notfound.php);
exit();

-

That pulls page content based on $REQUEST_URI. I build site menus from the
database, using values from the MenuPath field as URLs.

HTH

--
Lowell Allen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Hey Jason, Brad,
Thanks for replying.

I took out the .php part...and even tried it with [L] tacked to the end of
the second linenot working
Heres how my .htaccess looks now:

RewriteEngine On
RewriteRule ^show/(.*)/(.*)/(.*) /show.php?category=poetrysid=$2id=$3

I even took out the space which was in category.

Any ideas?

Thanks,
-Ryan


On 1/14/2004 8:11:47 PM, Brad Pauly ([EMAIL PROTECTED]) wrote:
 On Wed, 2004-01-14 at 11:44, Ryan A wrote:

 [snip]

  Its a bit hard to explain what happens so see for yourself:
  Heres the index page:
  http://www.rizkhan.net/articles/articles.php
  Heres the actual page:
  http://www.rizkhan.net/articles/show.
 php?category=Beginners%20Cornersid=1id=1
  and then if you modify it to:
  http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1

 [snip]

  Any ideas?

 One thing I noticed is that your rule is looking for a .php at the end
 so the above url will not match.

 RewriteEngine On
 RewriteRule ^show/(.*)/(.*)/(.*).php
 /show.php?category=Beginners%20Cornersid=$2id=$3

 I don't remember for sure, but do you need an [L] at the end of the
 second line?

 - Brad

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Brad Pauly
On Wed, 2004-01-14 at 12:41, Ryan A wrote:
 Hey Jason, Brad,
 Thanks for replying.
 
 I took out the .php part...and even tried it with [L] tacked to the end of
 the second linenot working
 Heres how my .htaccess looks now:
 
 RewriteEngine On
 RewriteRule ^show/(.*)/(.*)/(.*) /show.php?category=poetrysid=$2id=$3
 
 I even took out the space which was in category.
 
 Any ideas?

Do you have a print or echo in show.php to see if you are getting there?
I would work on getting the rule to take you to the right place first,
then worry about the variables.

- Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Lowell Allen
[snip]
 
 I took out the .php part...and even tried it with [L] tacked to the end of
 the second linenot working
 Heres how my .htaccess looks now:
 
 RewriteEngine On
 RewriteRule ^show/(.*)/(.*)/(.*) /show.php?category=poetrysid=$2id=$3
 
 I even took out the space which was in category.
 
 Any ideas?
 
[snip]

Make sure you upload the .htaccess file as ASCII mode, not binary. (That
wasted lots of my time recently.)

--
Lowell Allen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Hey,
Ok, have added echo Ok,we are in show.php; and if you go to 
http://rizkhan.net/articles/show/category/1/2 or
http://rizkhan.net/articles/show.php?category=poetrysid=1id=2

you will see that its echoing that without a problem..so this is
partly working.

now what to do about the variables?

Thanks,
-Ryan 
 
 Do you have a print or echo in show.php to see if you are getting there?
 I would work on getting the rule to take you to the right place first,
 then worry about the variables.
 
 - Brad
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Brad Pauly
On Wed, 2004-01-14 at 13:14, Ryan A wrote:
 Hey,
 Ok, have added echo Ok,we are in show.php; and if you go to 
 http://rizkhan.net/articles/show/category/1/2 or
 http://rizkhan.net/articles/show.php?category=poetrysid=1id=2
 
 you will see that its echoing that without a problem..so this is
 partly working.
 
 now what to do about the variables?

Well, are any of them in $_GET? If so, are they getting assigned to the
right place? How about putting a print_r($_GET) in show.php.

- Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Hey,
I put this in for testing:

if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
\$_GET[id]br;}
if(isset($_GET[sid])){echo Got \$_GET[sid]br;}else{echo No
\$_GET[sid]br;}

and heres the output:
No $_GET[id]
No $_GET[sid]

So the variables are not being passed
Any idea why and what I can do about this?
(Am a total newbie here)

Cheers,
-Ryan



On 1/14/2004 9:27:03 PM, Brad Pauly ([EMAIL PROTECTED]) wrote:
 On Wed, 2004-01-14 at 13:14, Ryan A wrote:
  Hey,
  Ok, have added echo Ok,we are in show.php; and if you go to
  http://rizkhan.net/articles/show/category/1/2 or
  http://rizkhan.net/articles/show.php?category=poetrysid=1id=2
 
  you will see that its echoing that without a problem..so this is
  partly working.
 
  now what to do about the variables?

 Well, are any of them in $_GET? If so, are they getting assigned to the
 right place? How about putting a print_r($_GET) in show.php.

 - Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Jason Wong
On Thursday 15 January 2004 05:01, Ryan A wrote:

 I put this in for testing:

 if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
 \$_GET[id]br;}
 if(isset($_GET[sid])){echo Got \$_GET[sid]br;}else{echo No
 \$_GET[sid]br;}

 and heres the output:
 No $_GET[id]
 No $_GET[sid]

 So the variables are not being passed
 Any idea why and what I can do about this?
 (Am a total newbie here)

As was previously suggested just do a 

  print_r($_GET)

to see what, if anything, you're getting.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Price's Advice:
It's all a game -- play it to have fun.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Oops sorry, missed that.

Heres whats on top of the page:

echo Ok,we are in show.phpbr;
if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
\$_GET[id]br;}
if(isset($_GET[sid])){echo Got \$_GET[sid]br;}else{echo No
\$_GET[sid]br;}
print_r($_GET);
print_r($_GET['id']);
print_r($_GET['sid']);

and heres the output:

Ok,we are in show.php
No $_GET[id]
No $_GET[sid]
Array ( )


Ideas?

Cheers,
-Ryan




On 1/14/2004 10:56:35 PM, Jason Wong ([EMAIL PROTECTED]) wrote:
 On Thursday 15 January 2004 05:01, Ryan A wrote:

  I put this in for testing:
 
  if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo
 No
  \$_GET[id]br;}
  if(isset($_GET[sid])){echo Got \$_GET[sid]br;}else{echo
 No
  \$_GET[sid]br;}
 
  and heres the output:
  No $_GET[id]
  No $_GET[sid]
 
  So the variables are not being passed
  Any idea why and what I can do about this?
  (Am a total newbie here)

 As was previously suggested just do a

 print_r($_GET)

 to see what, if anything,
 you're getting.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Price's
 Advice:
 It's all a game -- play it to have fun.
 */

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Brad Pauly
On Wed, 2004-01-14 at 15:11, Ryan A wrote:

[snip]

 and heres the output:
 
 Ok,we are in show.php
 No $_GET[id]
 No $_GET[sid]
 Array ( )
 
 
 Ideas?

Seems like you are getting closer. You are going to the right place, but
none of your variables are making it. I am not sure what your rule looks
like now, but at one point it was:

RewriteRule ^show/(.*)/(.*)/(.*) /show.php?category=poetrysid=$2id=$3

I would recommend trying just one variable first. See if you can get
that to work, then add the others one at a time. Maybe something like
this to start with:

RewriteRule ^show/(.*) /show.php?foo=$1

And see what $_GET looks like.

- Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Hey,
At least you remember what it used to look like, I dont!
Soo many modificatios in both .htaccess and httpd.conf and restarts...have
just lost track.

Will try your example one at a time and see what happens.

Thanks again.

Cheers,
-Ryan

 Seems like you are getting closer. You are going to the right place, but
 none of your variables are making it. I am not sure what your rule looks
 like now, but at one point it was:

 RewriteRule ^show/(.*)/(.*)/(.*) /show.php?category=poetrysid=$2id=$3

 I would recommend trying just one variable first. See if you can get
 that to work, then add the others one at a time. Maybe something like
 this to start with:

 RewriteRule ^show/(.*) /show.php?foo=$1

 And see what $_GET looks like.

 - Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Matt Matijevich
I am a little late but I have used the method described on a list apart
http://www.alistapart.com/articles/succeed/ and it works really
well.
You might want to give it a try, I think it works a little bit
different than the way you are trying.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Hi again,
I did a little pokeing around and installed this on 3 differient
serversand the results were identical...
so its not the servers fault but something with the directives...

got some interesting results with my testing

am using this:
echo Ok,we are in show.phpbr;
if(isset($_GET[id])){echo Got \$_GET[id]br;}else{echo No
\$_GET[id]br;}
if(isset($_GET[sid])){echo Got \$_GET[sid]br;}else{echo No
\$_GET[sid]br;}
print_r($_GET);

This is still not working:
http://rizkhan.net/articles/show/2/1
(output is:  )
Ok,we are in show.php
No $_GET[id]
No $_GET[sid]
Array ( )

This gives the exact expected results (working)
http://rizkhan.net/articles/show/?sid=1id=2 (note I dont have to write
show.php)

This gives me screwy results:
http://rizkhan.net/articles/show/?1/2
(output is:  )
Ok,we are in show.php
No $_GET[id]
No $_GET[sid]
Array ( [1/2] = )

in case you guys forgot, this is what i entered into my httpd.conf:

Directory /path/to/directory #of course i entered the correct path#
Options ExecCGI FollowSymLinks Includes MultiViews
AllowOverride all
/Directory

This is my htaccess file:

RewriteEngine On
RewriteRule ^show/(.*)/(.*) /show.php?sid=$1id=$2

incase i forgot to mention it...this #¤#¤# thing is not working.


ANY ideas?

Thanks,
-Ryan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Justin Patrin
RewriteEngine On
RewriteRule ^show/(.*)/(.*) /show.php?sid=$1id=$2
Try:
RewriteRule ^show/([^/]*)/([^/]*) /show.php?sid=$1id=$2
--
paperCrane Justin Patrin
--
Question Everything, Reject Nothing
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Ryan A
Hey,
Thanks for replying.

Nope, does not work.

Looks like I got a problem that finally stumped the whole listlucky me
:-p

Cheers,
-Ryan

On 1/15/2004 2:28:33 AM, Justin Patrin ([EMAIL PROTECTED]) wrote:
  RewriteEngine On
  RewriteRule ^show/(.*)/(.*) /show.php?sid=$1id=$2

 Try:
 RewriteRule ^show/([^/]*)/([^/]*) /show.php?sid=$1id=$2

 --
 paperCrane Justin Patrin
 --
 Question Everything, Reject Nothing

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Jason Wong
On Thursday 15 January 2004 09:28, Justin Patrin wrote:
  RewriteEngine On
  RewriteRule ^show/(.*)/(.*) /show.php?sid=$1id=$2

 Try:
 RewriteRule ^show/([^/]*)/([^/]*) /show.php?sid=$1id=$2

The original ought to work just fine -- I have it working here.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Don't put off for tomorrow what you can do today because if you enjoy it 
today,
you can do it again tomorrow.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Jason Wong
On Thursday 15 January 2004 09:42, Ryan A wrote:

 Nope, does not work.

 Looks like I got a problem that finally stumped the whole listlucky me

This works fine for me:

RewriteEngine On
RewriteRule ^show/(.*)/(.*)/(.*) /show.php?a=$1b=$2c=$3

What version of Apache/PHP are you using?
Have you checked bugs.php.net?
You're not using some weirdo operating system like Windows are you?

If all else fails you can use the 'parse the URL' method that I outlined 
earlier.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
It is now 10 p.m.  Do you know where Henry Kissinger is?
-- Elizabeth Carpenter
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] url rewriting within sessions - confused newbie needs help - [FIXED]

2003-12-14 Thread Peter Walter
I finally discovered the problem. There was extra whitespace after the 
php closing tag ? that was being interpreted as part of the header. 
Removing the whitespace fixed the problem.

Peter

Peter Walter wrote:
Mike,

I hope you mean session_start().

Yes,  I did. Getting a bit dyslexic nowadays.

Well, you would, because PHP would use the value from the PHPSESSID= URL 
parameter.

... except that on the second call, the url (as displayed by the 
browser) does not contain the PHPSESSID parameter, yet I am still able 
to retrieve the session variables correctly ...

My immediate reaction to this is that session.use_cookies must be set to 
0 (or Off) in your php.ini (or equivalent).  Have you checked this?  If 
it looks correct, what does a phpinfo() page show?

php.ini contains the following settings:
[Session]
session.save_handler  = files
session.save_path = /tmp
session.use_cookies   = 1
session.name  = PHPSESSID session.auto_start= 0
session.cookie_lifetime   = 0
session.cookie_path   = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability= 1
session.gc_maxlifetime= 1440
session.referer_check =
session.entropy_length= 0
session.entropy_file  =
session.cache_limiter = nocache
session.cache_expire  = 180
session.use_trans_sid = 1
url_rewriter.tags = 
a=href,area=href,frame=src,input=src,form=fakeentry

In phpinfo(), the local value matches the master value for all 
entries, and match the entries in php.ini.

I appreciate that this issue isn't a big deal - but I had hoped to 
understand php well enough to tell the difference between a bug and a 
feature. If it would help, I could send you the url for the page? 
(password protected)

Peter

Ford, Mike [LSS] wrote:

On 11 December 2003 18:01, Peter Walter wrote:

 

Mike,

Thanks for the additional explanation, and I understand the
sequence of events as you described. However,  please bear
with me a bit - the results I am getting do not quite match
your explanation. Let me clarify what I am doing:
I have a page (index.php) which starts out by calling
start_session(),
  


I hope you mean session_start().

 

then emits some html code containing some
form variables for search criteria. After the form variables,
I have a submit button that refers to index.php. Following
that, I have php logic that extracts the search criteria (if
set) from $HTTP_POST_VARS, performs a MySQL query, then
creates a table of results (if any); one of the table entries
contains a a href= link to determine which row the user selected.
The first time I load the page, I assume the session is
created by start_session(), and the cookie is sent to the
browser. When I click on the submit button, the page is
reloaded - I assume with the session active - as per your
explanation. According tho the documentation I have read, the
second time the page is loaded, start_session() will simply
reuse the existing session parameters. At this point, the
browser should already have the cookie - if it did not, I
would not be able to retrieve the session variables
  


Well, you would, because PHP would use the value from the PHPSESSID= 
URL parameter.

 

- but the
url links in the table are still rewritten. I do not understand why.
  


My immediate reaction to this is that session.use_cookies must be set 
to 0 (or Off) in your php.ini (or equivalent).  Have you checked 
this?  If it looks correct, what does a phpinfo() page show?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] url rewriting within sessions - confused newbie needs h elp

2003-12-12 Thread Ford, Mike [LSS]
On 11 December 2003 19:58, Peter Walter wrote:

 I hope you mean session_start().
 
 Yes,  I did. Getting a bit dyslexic nowadays.
 
 
 Well, you would, because PHP would use the value from the PHPSESSID=
 URL parameter. 
 
 ... except that on the second call, the url (as displayed by
 the browser) does not contain the PHPSESSID parameter, yet I
 am still able to retrieve the session variables correctly ...

Well, that seems right (and is different from your previous explanation).  Go back and 
read my original description of the process -- especially steps 5 and 6.  Once PHP 
knows that your browser is accepting cookies, it stops appending the PHPSESSID= URL 
parameters, and the cookie takes over the job.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] url rewriting within sessions - confused newbie needs help

2003-12-11 Thread Jason Wong
On Thursday 11 December 2003 14:16, Peter Walter wrote:
  From the book Core PHP programming, 3ed ;

 As stated earlier, PHP sends session identifiers with cookies, but a
 browser may refuse them. PHP can detect when a browser does not accept
 cookies, and in this situation it modifies all forms and links to
 include the session identifier.

 My php pages all include start_session() before any content is sent to
 the browser, and my browser is configured to accept cookies.
 Nevertheless, any coded relative url links (a href=...) are all
 modified to include PHPSESSID=12345, although the cookie *should* be
 set. I am using PHP 4.x. Why is this happening?

When your browser first hits the page (ie when no session has been started 
yet) the links and the URL will have the session ID appended. This is because 
at that stage the server does not know your browser is accepting cookies. 

When you continue browsing your browser will send the session cookie thus 
signalling to the server that cookies are being accepted and should then no 
longer append the session ID.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
90. Wowthat seemed _fast_.

--Top 100 things you don't want the sysadmin to say
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] url rewriting within sessions - confused newbie needs help

2003-12-11 Thread Peter Walter
Jason,

Thanks for your help. It is a little clearer to me now. However, I have 
visited php sites that *claim* to be using session management but where 
the links do not have the session id appended, and there are no 
variables being passed in the url for links. The url is always in the 
form www.somesite.com/index.php or just www.somesite.com. In these 
cases, how is the url rewriting being suppressed for the links on the 
page? I simply want to understand the technique.

Peter

Jason Wong wrote:
On Thursday 11 December 2003 14:16, Peter Walter wrote:

From the book Core PHP programming, 3ed ;

As stated earlier, PHP sends session identifiers with cookies, but a
browser may refuse them. PHP can detect when a browser does not accept
cookies, and in this situation it modifies all forms and links to
include the session identifier.
My php pages all include start_session() before any content is sent to
the browser, and my browser is configured to accept cookies.
Nevertheless, any coded relative url links (a href=...) are all
modified to include PHPSESSID=12345, although the cookie *should* be
set. I am using PHP 4.x. Why is this happening?


When your browser first hits the page (ie when no session has been started 
yet) the links and the URL will have the session ID appended. This is because 
at that stage the server does not know your browser is accepting cookies. 

When you continue browsing your browser will send the session cookie thus 
signalling to the server that cookies are being accepted and should then no 
longer append the session ID.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] url rewriting within sessions - confused newbie needs h elp

2003-12-11 Thread Ford, Mike [LSS]
On 11 December 2003 16:54, Peter Walter wrote:

 Jason,
 
 Thanks for your help. It is a little clearer to me now.
 However, I have
 visited php sites that *claim* to be using session management
 but where
 the links do not have the session id appended, and there are no
 variables being passed in the url for links. The url is always in the
 form www.somesite.com/index.php or just www.somesite.com.
 In these
 cases, how is the url rewriting being suppressed for the links on the
 page? I simply want to understand the technique.

If url rewriting (session.use_trans_sid) is enabled, and your browser is
accepting cookies, then the sequence of events goes like this:

1. First request to your site -- browser has no cookie set, so cannot send
it.

2. PHP responds with a page, including a header to set the PHPSESSID cookie;
because, at this stage, PHP has no idea whether your browser will accept
cookies, it also rewrites all URLs contained in the page to include a
PHPSESSID= parameter.

3. Your browser displays the page, and sets the cookie.

4. You click a link to get the next page -- in addition to sending a request
for the URL containing the PHPSESSID= parameter, your browser also sends the
newly-set PHPSESSID cookie.

5. PHP responds with the new page, but, because it has received the
PHPSESSID cookie in the previous step it now knows your browser is accepting
cookies and does not bother to do any URL rewriting.

6. None of the URLs in the new page have the PHPSESSID= parameter appended
-- transmission of the session id is now solely via the PHPSESSID cookie.

Various things can influence this behaviour:

- If your browser is not accepting cookies, URL rewriting will always occur
and you will continue to see PHPSESSID= parameters appended.

- If session.use_trans_sid is not set, PHP will do no URL rewriting but will
attempt to use cookies (if enabled) -- if your browser doesn't accept
cookies, sessions will fail to work (unless you manually append PHPSESSID=
parameters where needed -- the SID built-in constant is provided for this).

- If session.use_cookies is not set, PHP will not even attempt to use a
cookie for the session id.

- If session.use_only_cookies is set, PHP will use *only* cookies to store
the session id -- again, if your browser is not accepting cookies, sessions
will not work.

As you can see, there are many ways of setting this up, with a few subtle
nuances -- and some of the combinations don't actually make much sense
(use_trans_sid=1 and use_only_cookies=1, for instance).  Note that you *can*
set it up so that PHP does no automatic PHPSESSID setting at all
(use_trans_sid=0 and use_cookies=0) -- then it's up to you to manually
append the PHPSESSID= parameter to all appropriate URLs.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] url rewriting within sessions - confused newbie needs h elp

2003-12-11 Thread Peter Walter
Mike,

Thanks for the additional explanation, and I understand the sequence of 
events as you described. However,  please bear with me a bit - the 
results I am getting do not quite match your explanation. Let me clarify 
what I am doing:

I have a page (index.php) which starts out by calling start_session(), 
then emits some html code containing some form variables for search 
criteria. After the form variables, I have a submit button that refers 
to index.php. Following that, I have php logic that extracts the search 
criteria (if set) from $HTTP_POST_VARS, performs a MySQL query, then 
creates a table of results (if any); one of the table entries contains a 
a href= link to determine which row the user selected.

The first time I load the page, I assume the session is created by 
start_session(), and the cookie is sent to the browser. When I click on 
the submit button, the page is reloaded - I assume with the session 
active - as per your explanation. According tho the documentation I have 
read, the second time the page is loaded, start_session() will simply 
reuse the existing session parameters. At this point, the browser should 
already have the cookie - if it did not, I would not be able to retrieve 
the session variables - but the url links in the table are still 
rewritten. I do not understand why.

Being new to the stateless paradigm of web applications, and to php, I 
feel a bit nervous about coding when I do not quite grasp what is going on.

Peter

Ford, Mike [LSS] wrote:

On 11 December 2003 16:54, Peter Walter wrote:

 

Jason,

Thanks for your help. It is a little clearer to me now.
However, I have
visited php sites that *claim* to be using session management
but where
the links do not have the session id appended, and there are no
variables being passed in the url for links. The url is always in the
form www.somesite.com/index.php or just www.somesite.com.
In these
cases, how is the url rewriting being suppressed for the links on the
page? I simply want to understand the technique.
   

If url rewriting (session.use_trans_sid) is enabled, and your browser is
accepting cookies, then the sequence of events goes like this:
1. First request to your site -- browser has no cookie set, so cannot send
it.
2. PHP responds with a page, including a header to set the PHPSESSID cookie;
because, at this stage, PHP has no idea whether your browser will accept
cookies, it also rewrites all URLs contained in the page to include a
PHPSESSID= parameter.
3. Your browser displays the page, and sets the cookie.

4. You click a link to get the next page -- in addition to sending a request
for the URL containing the PHPSESSID= parameter, your browser also sends the
newly-set PHPSESSID cookie.
5. PHP responds with the new page, but, because it has received the
PHPSESSID cookie in the previous step it now knows your browser is accepting
cookies and does not bother to do any URL rewriting.
6. None of the URLs in the new page have the PHPSESSID= parameter appended
-- transmission of the session id is now solely via the PHPSESSID cookie.
Various things can influence this behaviour:

- If your browser is not accepting cookies, URL rewriting will always occur
and you will continue to see PHPSESSID= parameters appended.
- If session.use_trans_sid is not set, PHP will do no URL rewriting but will
attempt to use cookies (if enabled) -- if your browser doesn't accept
cookies, sessions will fail to work (unless you manually append PHPSESSID=
parameters where needed -- the SID built-in constant is provided for this).
- If session.use_cookies is not set, PHP will not even attempt to use a
cookie for the session id.
- If session.use_only_cookies is set, PHP will use *only* cookies to store
the session id -- again, if your browser is not accepting cookies, sessions
will not work.
As you can see, there are many ways of setting this up, with a few subtle
nuances -- and some of the combinations don't actually make much sense
(use_trans_sid=1 and use_only_cookies=1, for instance).  Note that you *can*
set it up so that PHP does no automatic PHPSESSID setting at all
(use_trans_sid=0 and use_cookies=0) -- then it's up to you to manually
append the PHPSESSID= parameter to all appropriate URLs.
Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 
 



RE: [PHP] url rewriting within sessions - confused newbie needs h elp

2003-12-11 Thread Ford, Mike [LSS]
On 11 December 2003 18:01, Peter Walter wrote:

 Mike,
 
 Thanks for the additional explanation, and I understand the
 sequence of events as you described. However,  please bear
 with me a bit - the results I am getting do not quite match
 your explanation. Let me clarify what I am doing:
 
 I have a page (index.php) which starts out by calling
 start_session(),

I hope you mean session_start().

  then emits some html code containing some
 form variables for search criteria. After the form variables,
 I have a submit button that refers to index.php. Following
 that, I have php logic that extracts the search criteria (if
 set) from $HTTP_POST_VARS, performs a MySQL query, then
 creates a table of results (if any); one of the table entries
 contains a a href= link to determine which row the user selected.
 
 The first time I load the page, I assume the session is
 created by start_session(), and the cookie is sent to the
 browser. When I click on the submit button, the page is
 reloaded - I assume with the session active - as per your
 explanation. According tho the documentation I have read, the
 second time the page is loaded, start_session() will simply
 reuse the existing session parameters. At this point, the
 browser should already have the cookie - if it did not, I
 would not be able to retrieve the session variables

Well, you would, because PHP would use the value from the PHPSESSID= URL parameter.

  - but the
 url links in the table are still rewritten. I do not understand why.

My immediate reaction to this is that session.use_cookies must be set to 0 (or Off) in 
your php.ini (or equivalent).  Have you checked this?  If it looks correct, what does 
a phpinfo() page show?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] url rewriting within sessions - confused newbie needs help

2003-12-11 Thread Peter Walter
Mike,

I hope you mean session_start().

Yes,  I did. Getting a bit dyslexic nowadays.

Well, you would, because PHP would use the value from the PHPSESSID= URL parameter.

... except that on the second call, the url (as displayed by the 
browser) does not contain the PHPSESSID parameter, yet I am still able 
to retrieve the session variables correctly ...

My immediate reaction to this is that session.use_cookies must be set to 0 (or Off) in your php.ini (or equivalent).  Have you checked this?  If it looks correct, what does a phpinfo() page show?

php.ini contains the following settings:
[Session]
session.save_handler  = files
session.save_path = /tmp
session.use_cookies   = 1
session.name  = PHPSESSID 
session.auto_start= 0
session.cookie_lifetime   = 0
session.cookie_path   = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability= 1
session.gc_maxlifetime= 1440
session.referer_check =
session.entropy_length= 0
session.entropy_file  =
session.cache_limiter = nocache
session.cache_expire  = 180
session.use_trans_sid = 1
url_rewriter.tags = 
a=href,area=href,frame=src,input=src,form=fakeentry

In phpinfo(), the local value matches the master value for all 
entries, and match the entries in php.ini.

I appreciate that this issue isn't a big deal - but I had hoped to 
understand php well enough to tell the difference between a bug and a 
feature. If it would help, I could send you the url for the page? 
(password protected)

Peter

Ford, Mike [LSS] wrote:

On 11 December 2003 18:01, Peter Walter wrote:

 

Mike,

Thanks for the additional explanation, and I understand the
sequence of events as you described. However,  please bear
with me a bit - the results I am getting do not quite match
your explanation. Let me clarify what I am doing:
I have a page (index.php) which starts out by calling
start_session(),
   

I hope you mean session_start().

 

then emits some html code containing some
form variables for search criteria. After the form variables,
I have a submit button that refers to index.php. Following
that, I have php logic that extracts the search criteria (if
set) from $HTTP_POST_VARS, performs a MySQL query, then
creates a table of results (if any); one of the table entries
contains a a href= link to determine which row the user selected.
The first time I load the page, I assume the session is
created by start_session(), and the cookie is sent to the
browser. When I click on the submit button, the page is
reloaded - I assume with the session active - as per your
explanation. According tho the documentation I have read, the
second time the page is loaded, start_session() will simply
reuse the existing session parameters. At this point, the
browser should already have the cookie - if it did not, I
would not be able to retrieve the session variables
   

Well, you would, because PHP would use the value from the PHPSESSID= URL parameter.

 

- but the
url links in the table are still rewritten. I do not understand why.
   

My immediate reaction to this is that session.use_cookies must be set to 0 (or Off) in your php.ini (or equivalent).  Have you checked this?  If it looks correct, what does a phpinfo() page show?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

 



RE: [PHP] URL Rewriting

2002-09-23 Thread Jon Haworth

Hi Bill,

 I've been using PHP for a couple of years now and only
 recently (since upgrading to RH7.3) began to
 experience an odd problem.  When navigating around my
 site or when I run HT://Dig across it the links are
 suddenly being rewritten back as
 http://my.dom.com/some_page?PHPSESSID=the_id_string. 
 I haven't changed my coding between releases so evidently
 whatever I've been doing with session variables all
 along is suddenly behaving differently between
 releases.

Your new installation looks like it has the enable_trans_sid option turned
on: this option governs whether PHP will transparently rewrite links for
users without cookies - htdig is one of these presumably ;-)

You'll find that your forms have a new input type=hidden field as
well, containing the session ID.

It can be turned off in php.ini, but I think this might break sessions for
non-cookie-accepting users (not sure).


Cheers
Jon



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php