473,395 Members | 1,629 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,395 software developers and data experts.

rewriting URLs

Hi,

here's my problem. On my pages I have URL souch as these
"page.php?id=2&subpage=3&param=65". For security reasons I would like to add
another parameter. It would be created like this
md5($param1.$param2.$some_constant). I would then add that MD5 string to my URL
and stop users from altering URL manually.
I would like PHP to rewrite all my URLs in a page adding this string to each
URL. I thought that I can pass a custom function to the session URL rewriting
but I cant it just adds the session ID. I know about
output_add_rewrite_var('var', 'value'); but the $value is fixed and in my case
it should depend on the specific URL being rewritten.
I know I could cache all my output and then write a regular expression to
rewrite URLs but that just seems slow and wrong :-)

any help is highly appreciated
gordan

Jul 17 '05 #1
6 1691
*** Gordan wrote/escribió (Thu, 16 Jun 2005 13:43:55 +0200):
here's my problem. On my pages I have URL souch as these
"page.php?id=2&subpage=3&param=65". For security reasons I would like to add
another parameter. It would be created like this
md5($param1.$param2.$some_constant). I would then add that MD5 string to my URL
and stop users from altering URL manually.


Then you should be using a more secure mechanism, such as sessions. URL
parameters are useful when user cannot break anything or even is encouraged
to alter it.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #2
Gordan wrote:
here's my problem. On my pages I have URL souch as these
"page.php?id=2&subpage=3&param=65". For security reasons I would like to add
another parameter. It would be created like this
md5($param1.$param2.$some_constant). I would then add that MD5 string to my URL
and stop users from altering URL manually.
I would like PHP to rewrite all my URLs in a page adding this string to each
URL. I thought that I can pass a custom function to the session URL rewriting
but I cant it just adds the session ID. I know about
output_add_rewrite_var('var', 'value'); but the $value is fixed and in my case
it should depend on the specific URL being rewritten.
I know I could cache all my output and then write a regular expression to
rewrite URLs but that just seems slow and wrong :-)


You seems to be right. AFAIK, the better option is
<http://in.php.net/ob_start> and <http://in.php.net/preg_replace>--yes,
it's slow.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 17 '05 #3
hi gordan.
i believe what you are trying to do is to "encrypt" your URL's so users
can`t mess with parameters.
once i did a script which did exactly that. i can't copy&paste here but
i'll give you some VERY basic pointers (it's a simple script but very
hard to explain here!).
i created 2 pages: a.php and z.php. a.php created the "encrypted" links
and z.php read them.
a.php converted automatically the URL's to the new "encrypted" format
using Output Buffering, a simple preg_replace() function and another
function to encrypt the parameters.
the preg function returned the parameters of the URL's (i.e.
?p1=v1&p2=v2) and the "encrypting" function transformed those
parameters using base64 encode.
z.php receieved the new parameter and "uncrypted" it using base64
decode and then parsed the result to make a new $_GET array.

Jul 17 '05 #4
A tada saintexupery rece:
i believe what you are trying to do is to "encrypt" your URL's so
users can`t mess with parameters.


exactly that! :-)

<cut>
thanks for the idea. I was just wondering if I have to use output buffering. I
know I can change every single link in my page into
encode_this_link('xxx.php?id=4'); but that would take timeeeeeeee and I want
something automatic.
Ill write something using output buffering and regular expressions

thanks!
gordan
Jul 17 '05 #5
I don't see anything particularly insecure with the design. He's
basically attaching a digital signature of the GET parameters. If the
objective is simply to stop people from going to arbituary pages, it
would work.

Jul 17 '05 #6
*** Chung Leong <ch***********@hotmail.com> wrote/escribió (17 Jun 2005
08:39:54 -0700):
If the objective is simply to stop people from going to arbituary pages,
it would work.


I enclose "Going to arbitrary pages" in the "cannot break anything"
category.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #7

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

Similar topics

6
by: Jon Maz | last post by:
Hi All, I am experimenting with URL Rewriting using the techniques outlined by Scott Mitchell in his article "URL Rewriting in ASP.NET"...
7
by: go | last post by:
Can someone please tell me what URL rewriting is? I don't understand . . . a client is asking me to rewrite his URLs.
3
by: Michael Appelmans | last post by:
I'm trying to use a rule based URL rewrite application which uses HttpApplication.RewritePath. I keep getting "rsource not found" error in application when running on shared web host although the...
0
by: Lee | last post by:
Hi all ;) Preamble -------- I'm using URL rewriting to enforce a frames policy (yeah, I know frames are 'bad' :) - i.e. if a request comes in for a page which should be nested within a...
2
by: KMA | last post by:
My site has dynamicaly generated pages. Most of the URLs are false, and I used to trap them in a generic 404 page, which stripped off a unique part of the URL, built the page then sent that back to...
3
by: Greg Collins [Microsoft MVP] | last post by:
I have done a bit of research of Url Rewriting, but as yet have been unsuccessful at getting it to work well, and there are issues around what file types are supported and how much code you want to...
0
by: Moinak Bhattacharya | last post by:
Hi, We are using URL rewriting to display user friendly URL in the address bar for the pages requested. For this, physical pages are mapped to the logical urls by regexp in HTTPModules. But the...
8
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm having trouble with URL rewriting using HttpApplication.Context.RewritePath in a web application I've created. Everything works, but the links (css, images) in the pages break when...
3
by: Toni | last post by:
Does anyone have a recommended method of rewriting URLs with classic ASP? For example, if the browser shows the Friendly URL www.mydomain.com/blue_widget my app will show the following Content...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.