Jump to content


Photo

Pass non-existing page to PHP


  • Please log in to reply
4 replies to this topic

#1 Willem_ZA

Willem_ZA
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 03 June 2006 - 01:15 PM

Hey guys

I'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

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 03 June 2006 - 02:06 PM

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]

Redirect /aa12 /catch.php

(if it doesn't work use full paths)
~ D Kuang

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 June 2006 - 02:09 PM

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

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 03 June 2006 - 02:23 PM

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=de12

Then you can retrieve it using $_GET['c']
~ D Kuang

#5 Willem_ZA

Willem_ZA
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 03 June 2006 - 02:44 PM

[!--quoteo(post=379626:date=Jun 3 2006, 04:23 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 3 2006, 04:23 PM) View Post[/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=de12

Then 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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users