Jump to content

Pass non-existing page to PHP


Willem_ZA

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/11081-pass-non-existing-page-to-php/
Share on other sites

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)
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']
[!--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=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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.