Redirect URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Redirect URL

Post by anjanesh »

If someone enters the url mydomain.com/AAA I want it to redirect to mydomain.com?id=AAA
There is no folder called AAA

Any way to detect this other than using htaccess ?

Thanks
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

I asked a question similar to this.

I believe the only way is to use mod_rewrite in your .htaccess file.
So, I don't believe their is any other way.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

just a brainstorm here

perhaps make a custom 404 page (that will come up when they type in the URL that's not valid such as domain.com/AAA)

include a PHP script at the top of the 404 page, that uses a regex to determine what's after the / in the URL they entered. Then use a header("Location: page.php?var=$typedinurl");

Just an idea though, I have no clue if it would actually work.
Post Reply