Passing vars into PHP

Discuss practical ways rearrange URLs using mod_rewrite.

Passing vars into PHP

Postby Guest » Sun Mar 27, 2005 3:56 pm

Hi there,

I have been trying to get my mod_rewrite code to work for ages now, and it works fine but for whatever reasion it will not pass the on the values for php to read.

Code: Select all
RewriteEngine On
RewriteRule ^play/([0-9]+)/? play.php?id=$1 [L]


when you request play/35/
play.php is displayed but the value of 'id' nothing?


Any ideas anyone?
Thanks Owen,
Guest
 

Postby Caterham » Mon Mar 28, 2005 6:12 am

make sure that mod_rewrite is available and you are allowes to use it in .htaccess files.
use
RewriteEngine On
RewriteRule ^123/([0-9]+)/? play.php?id=$1 [L]
instead and call /123/2332. If you get a 404, try
RewriteEngine On
RewriteBase /
RewriteRule ^123/([0-9]+)/? /play.php?id=$1 [L]



If you have MultiViews enabled, Content Negotiation will search for similar files, if a file does not exsist. You're calling /play/123. /play/ is not a directory, so Content Negotiation will try to find a file starting with /play (if mod_rewrite is not allowed in .htaccess files). And that's play.php

in play.php you should find via
Code: Select all
$_SERVER['PATH_INFO'];
the value
/35/
(from your example play/35/ )
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 19 guests

cron