Re: [PHP-DB] URL question. .
Mark Cain wrote: a 404 script is the way I would handle it. [snip] - Original Message - From: Chris Payne [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Friday, April 29, 2005 11:00 PM Subject: [PHP-DB] URL question Hi there everyone, My client needs to be able to have their url www.blahblah.com http://www.blahblah.com/ pickup the product number but I can't do it the way I'd want (which would be www.blahblah.com/?mls=examplenumber, instead they said it MUST be www.blahblah.com/examplenumber - how can I grab the number AFTER the .com in PHP so that I can process it with MySQL without it being assigned a variable name, just the number? [snip] You might also want to use apache mod_rewrite http://httpd.apache.org/docs/mod/mod_rewrite.html e.g. .htaccess RewriteEngine On RewriteRule ^/prod/(.*)$ product.php?pid=$1 [R] I don't see that there's any easy way to trap a 404 error and rewrite based on that, you might be able to check if the requested object existed beforehand and set an ENV var to check against. I don't know whether the straight 404 work would be easiest, or whether you might want to combine the two. If you absolutely can't have any other pieces in the URL that you can uniquely tie to product lookups, you'll have a hard time doing this with just mod_rewrite, so the 404 may be the way to go. Still, something to be aware of. You could also do a rewrite map if the products are sufficiently static, though in that case you could also just alias it / etc. cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] URL question
Hi there everyone, My client needs to be able to have their url www.blahblah.com http://www.blahblah.com/ pickup the product number but I can't do it the way I'd want (which would be www.blahblah.com/?mls=examplenumber, instead they said it MUST be www.blahblah.com/examplenumber - how can I grab the number AFTER the .com in PHP so that I can process it with MySQL without it being assigned a variable name, just the number? Chris
Re: [PHP-DB] URL question
a 404 script is the way I would handle it. Modify what the server does when it finds a page that doesn't exist. Currently the server issues 404 headers and displays a brain dead message about not being able to find the page. Change that so that the server issues 200 headers (tricking the client which has friendly error message enabled) and pick off the part after the .com/ and do a look up for the item. If found, proceed as expected, it not found display, a brain dead 404 message. How do you modify the server? Either modify the 404 directive in Apache or one of the other lesser products or setup a .htaccess file on their domain The .htaccess has a line that says: ErrorDocument 404 /new.php Which means when the page is not found display the page /new.php Build your product look up and place it in the file new404.php Be sure that the first line of new.php is ?header(HTTP/1.0 200 OK); That's the header that tricks the Friendly Error Message I wish I had come across this info as easily as you just did! Mark Cain - Original Message - From: Chris Payne [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Friday, April 29, 2005 11:00 PM Subject: [PHP-DB] URL question Hi there everyone, My client needs to be able to have their url www.blahblah.com http://www.blahblah.com/ pickup the product number but I can't do it the way I'd want (which would be www.blahblah.com/?mls=examplenumber, instead they said it MUST be www.blahblah.com/examplenumber - how can I grab the number AFTER the .com in PHP so that I can process it with MySQL without it being assigned a variable name, just the number? Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php