Link to home
Create AccountLog in
Avatar of WestCoast_BC
WestCoast_BCFlag for Canada

asked on

Hiding URLs

Right now my coldfusion website passes variables via the URL.  Ie, www.mysite.com?var1=text&var2=number.

Without making changes like changing the anchors to form posts is there any way to hide the variables passed in the URL?

Any help I can get is very much appreciated.
Avatar of _agx_
_agx_
Flag of United States of America image

No. URL parameters are meant to be visible. You can only obfuscate them OR not use them at all ie Which means using method="post" (which you said you do not want) OR storing the values in session variables instead.

I'm curious - what is your reason for wanting to hide them?
Avatar of WestCoast_BC

ASKER

My client would prefer not to display all the variables in the URL.  I am hoping not to redesign the whole site to do this.
You would need to change the link to a form submit and put the values in a hidden input tag.
oop, sat on the page too long..

I like agx's suggestion of encoding the values in some way...

The question is, would the like be ok if the values were not readable/understandable, but still there?

If the client wants to avoid having those values bookmarkable, that's a bit more complex as the URL needs to expire as well.
How would I encode/decode the URL variables?
I just found this link on the web: http://roshanbh.com.np/2008/04/hide-url-display-same-url-website.html

Here is his comment:
Do you want to hide the actual URL in the address-bar? Do you want to display the same url throughout the website? Then here is the tips for you do the same in your website. Just display the same URL i.e http://www.your-site.com throughout your website in address bar, no matter if you in the page http://www.your-site.com/aboutus.html.


Live Demo

As you can see demo, it displays the same url throughout the browser’s address bar.But you are navigating to different page like aboutus.html or services.html. Ok, too much explanation, now let’s know how to do it.

1) First of create, all the other relavant page like “services.html” or “contactus.html” as usual.
2) For home page, rename the actual index page like “index.html” or “index.php” as “home.html” or “home.php” or whatever name you’re comfortable with.
3)Now, in the index page like “index.html” or “index.php”, put the following code

<iframe src="home.html" width="100%" height="100%" frameborder="0" scrolling="no" />

As, you can see above, we’ve used iframe to display the “home.html” page in the home page by using “src” attribute. The width and height should be “100%” and border should be ” ” for hiding the actual URL from the browser and displaying it so normal.

When a new link is clicked in the page, it gets loaded within “iframe” and displays the same URL throughout the website.

Is it possible to do this by having my entire website in an iframe?
>   My client would prefer not to display all the variables in the URL.

Ok, but why?  The right approach is going to be dictated by the reason for wanting to hide them. For example, it it's for security, then switching to a form post wouldn't help, because it's just the illusion of security by obscurity.

       >  it gets loaded within “iframe”

Personally I avoid any kind of frames when possible. iframes make it difficult for users to bookmark pages. Also iframes can have additional security restrictions regular pages don't.
You ask a good question and I don't have the answer.  I think it is time to talk to my client to ask why they want the URL hidden.
> to ask why they want the URL hidden.

And the details... is it the page link or specific variables in the query string... if particular values in the query string, which ones?

For example, if the client wants to hide the users ID from the URL, then this could be put into a session variable.

.. as agx said, the answer depends on the reasons/requirements
I have finally received feedback about this and they want to hide passed variables in the URL so that it (in their mind) the URL looks 'cleaner'.  The problem is that it will not be possible for a user to bookmark pages if the variables are not included in the URL.  We have decided to put this feature on hold for now.
This may be a time to look into the friendlier SEO style URL instead of IDs.

For example, if you have a product page that you may have a url..

 mySite.com/product_id=1983873&company_id=39834

You could switch it to...

 mySite.com/Mircosoft/operating-systems-windows-7/


Now that we know the intent, that may be a good alternative for you..
Thanks for the above but can you explain it some more to me.   I don't understand how :
 mySite.com/product_id=1983873&company_id=39834

is the same as:

 mySite.com/Mircosoft/operating-systems-windows-7/
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer