Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / October 2006



Tip: Looking for answers? Try searching our database.

Javascript Q2: Check URL else redirect

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M@r(o - 31 Oct 2006 15:12 GMT
On our site we have contentitems which suppose to be embedded in a
productsheet.
My idea is to check the URL to see if the item is opened the way it
should.
EG:
the URL
http://www.lelystad.nl/smartsite.shtml?id=11096
Should be
http://www.lelystad.nl/smartsite.shtml?id=23252&prodid=11096

How do I make a script to check if the page is opened the right way and
if it isn't redirect it to the right page with the 'id' as 'prodid'?

TIA
Marco
shimmyshack - 31 Oct 2006 16:43 GMT
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 ]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.