Javascript Q2: Check URL else redirect

S

shimmyshack

use server side programming for this. You dont just want to ensure they
are present, yuo want to validate them as well (so a variable that
should be an integer contains 0-9 n number of times.)

javascript wont work as anyone worth their salt messing with your url
will just turn off the bit of javascript you write, and the request
will still make it to the script before javascript catches it


you could use apache rewrites using search engine friendly urls like
this (having / instead of &)

http://my.site.com/path/script/var1/var2/var3/

then you use apache rewrites to ensure that not only are all the vars
present (or it redirects) but they are of the right length and type
using regular expressions.

or using php you would create an array of rewuired vars in your script.
If one isnt right redirect using the header function.

<?php
$arrRequiredGetVars = array( 'me' , 'metoo', 'methree' );
//if all exist and pass validation
{
//execute script;
}
else
{
header( 'Location:
http://my.site.com/path/script/error/error_number/' );
}
?>

obviously Apache ReWrites are easier to maintain but hard coding the
validation in the script is bomb proof.
[see alt.apache.configuration or Professional PHP Developers ]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top