Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custom urls

Status
Not open for further replies.

endeavor88

Programmer
May 3, 2005
4
0
0
US
How can I redirect a user based on the url he typed in. Here's what I mean: If I was making a dictionary, then let's say that the user types in Now I need to redirect to a server script, and give a variable to that script with the value of "word". I tried to use AliasMatch, and similar directives in mod_alias, but I'm not familiar with them. So I'm not sure if it would work using those. How can I accomplish this task??
 

If you know perl, and CGI module, or mod_perl and Apache::ASP module then your job is easy.
If you don't then this is a good chance to get to know 'em.


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Alternatively;

Perl has a data structure for matching regular expressions which is very handy. With two or three lines of code you could take the URL, parse it,look for the word after the last '/', and open the corresponding file.

The thing I don't know about is, if you could make Apache open the cgi/perl progam as the default 'home' page for ALL URLs, run the code, and only then open the desired page.
 
First, you catch the error. This is in Apache. With this line:
ErrorDocument 404 /erro.php
In htttpd.conf, the apache configuration file.

With this, when someone try to access a page what don’t exist, this page will be processed.

Then you catch the original URL. This is a PHO code.

<?php
print $_SERVER[REQUEST_URI];
?>

What you need to do is to redirect. Maybe:

<?php
header('location:/newpage.php?'. $_SERVER[REQUEST_URI]);
?>

This works. You have RFM to make things right, but the idea is ok.

Suggestions: make ti in steps.
1 - solve the ERROR capture problem with Apache.
2 – make your own cod (PHP, ASP< ???) page.
3 – don’t forget that real erros go to this page also!!!

Tell me if you make this works.

Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top