Willem_ZA Posted June 3, 2006 Share Posted June 3, 2006 Hey guysI'm not sure if this is exactly a PHP question, maybe more on the web server side?Anyway, I'm trying to write a program that will accept the address to a fictional page, and pass that address to PHP as a variable.Explanation:1. User visits "http://www.somepage.com/aa12/" or "http://www.somepage.com/de12/" (these pages don't really exist on the server)2. User gets redirected to "http://www.somepage.com/catch.php", and "aa12" or "de12" or whatever page he tried to visit, is passed to catch.php as a variable.In other words, I want to have a variable inside catch.php that will tell me what page the user tried to visit.Thanks!Willem Quote Link to comment https://forums.phpfreaks.com/topic/11081-pass-non-existing-page-to-php/ Share on other sites More sharing options...
poirot Posted June 3, 2006 Share Posted June 3, 2006 I don't know if you can do this with PHP, but with .htaccess it's easy:[a href=\"http://www.javascriptkit.com/howto/htaccess7.shtml\" target=\"_blank\"]http://www.javascriptkit.com/howto/htaccess7.shtml[/a][code]Redirect /aa12 /catch.php[/code](if it doesn't work use full paths) Quote Link to comment https://forums.phpfreaks.com/topic/11081-pass-non-existing-page-to-php/#findComment-41451 Share on other sites More sharing options...
kenrbnsn Posted June 3, 2006 Share Posted June 3, 2006 You want to create custom error pages. These can be done in PHP. If you are using the Apache web server, I would ask this question in that forum.Ken Quote Link to comment https://forums.phpfreaks.com/topic/11081-pass-non-existing-page-to-php/#findComment-41453 Share on other sites More sharing options...
poirot Posted June 3, 2006 Share Posted June 3, 2006 Ken, I think he doesn't want custom error pages.And besides, these are defined by .htaccess as well.He wants to redirect the users to a certain script... An advice though:Don't use this if you are going to have a BIG amount of pages: you would have to create redirects for each one of them. Instead, give the users a link like this:catch.php?c=aa12 or catch.php?c=de12Then you can retrieve it using $_GET['c'] Quote Link to comment https://forums.phpfreaks.com/topic/11081-pass-non-existing-page-to-php/#findComment-41457 Share on other sites More sharing options...
Willem_ZA Posted June 3, 2006 Author Share Posted June 3, 2006 [!--quoteo(post=379626:date=Jun 3 2006, 04:23 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 3 2006, 04:23 PM) [snapback]379626[/snapback][/div][div class=\'quotemain\'][!--quotec--]Ken, I think he doesn't want custom error pages.And besides, these are defined by .htaccess as well.He wants to redirect the users to a certain script... An advice though:Don't use this if you are going to have a BIG amount of pages: you would have to create redirects for each one of them. Instead, give the users a link like this:catch.php?c=aa12 or catch.php?c=de12Then you can retrieve it using $_GET['c'][/quote]No, I don't think it's custom error pages either.I don't want to use the GET or POST methods, I want it to look like it is an actual page. However, there will be many of these 'aa12' or 'de12' variants, the code refers to a specific record in a database.In other words, when a user goes to "http://www.mypage.com/aa12", I want the "aa12" value to be sent to "catch.php", then catch.php will display the related record for aa12.When a user goes to "http://www.mypage.com/dcee1", I want the "dcee1" value to be sent to "catch.php", then catch.php will display the related record for dcee1.When a user goes to "http://www.mypage.com/ea7", I want the "ea7" value to be sent to "catch.php", then catch.php will display the related record for ea7.For an example of what I want to do, look at "http://www.flickr.com/photos/tags/photo". There is no actual page, there, the Flickr server accepts the "photo" value at the end, and displays a page containing all the images (records) with a "photo" tag. If I go to "http://www.flickr.com/photos/tags/house", it displays all images (records) with a "house" tag. And, if I go to "http://www.flickr.com/photos/tags/houseaaaaaaa", it displays a page notifying me that there is no such record.W Quote Link to comment https://forums.phpfreaks.com/topic/11081-pass-non-existing-page-to-php/#findComment-41462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.