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
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)
Link to comment
Share on other sites

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']
Link to comment
Share on other sites

[!--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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.