473,378 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Javascript Q2: Check URL else redirect

M
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.sht...2&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

Oct 31 '06 #1
1 2314
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 ]

Oct 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.