[Solved] Simpler URL

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
RussCraig
Profound User
Posts: 62
Joined: Wed May 05, 2010 10:13 am
First Name: Russell
Last Name: Craig
Company Name: Applied Business Services
Phone: 252-482-7666
Address 1: 617 Soundside Rd
City: Edenton
State / Province: North Carolina
Zip / Postal Code: 27932
Country: United States
Location: Edenton, NC
Contact:

[Solved] Simpler URL

Post by RussCraig »

Hi Everyone,

Forgive my limited HTTP experience, but I was hoping someone could help. We currently make use of the "workstnid" and "suffixid" parameters in the ProfoundUI URL. This is used to prevent duplicate device errors and allow up to 35 simultaneous logins per unique URL.

We use some Javascript on our website to generate a random "workstnid" in the URL, from PUIWEB1 to PUIWEB99. This is done to allow up to 3500 users (though we'll never even come close to that). It works great. Here is what our current URL looks like:

Code: Select all

<script type="text/javascript">
	var str = "Client Portal";
	document.write(str.link("https://xxx.xxx.xxx.com/profoundui/start?pgm=RECLIB/PUIMENUCL&workstnid=PUIWEB" + (Math.floor(Math.random()*99)) + "&suffixid=1"));
</script>
However, when we give a link to a client (as opposed to just telling them to go to our website and click on the link there), we have to give them the entire URL, like this:

Code: Select all

https://xxx.xxx.xxx.com/profoundui/start?pgm=RECLIB/PUIMENUCL&workstnid=PUI####&suffixid=1
The #### is set to their assigned client number, so something like PUI0572. This doesn't matter program-wise, just for a unique workstnid.

My question is this: would it be possible to have a simpler URL, but achieve the same result? Perhaps some URL rewriting in the httpd.conf file? We would like to hand out a simple URL to our clients, something along the lines of "https://xxx.xxx.xxx.com/" or "https://xxx.xxx.xxx.com/client". Perhaps this would also eliminate the need for the Javascript-generated unique URLs?

Any help is much appreciated. Thanks!
Last edited by RussCraig on Thu Mar 03, 2011 10:10 am, edited 1 time in total.
There are 10 types of people in this world: Those who understand binary and those who don't.
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Simpler URL

Post by David »

Apache does allow for URL rewriting through the httpd.conf file. I'm not familiar with the process, but I've heard that it's a bit complicated and also not very well documented:

http://httpd.apache.org/docs/current/mo ... write.html

It seems like it could definitely be used to accomplish what you are looking for, though, with a bit of figuring out.
RussCraig
Profound User
Posts: 62
Joined: Wed May 05, 2010 10:13 am
First Name: Russell
Last Name: Craig
Company Name: Applied Business Services
Phone: 252-482-7666
Address 1: 617 Soundside Rd
City: Edenton
State / Province: North Carolina
Zip / Postal Code: 27932
Country: United States
Location: Edenton, NC
Contact:

Re: Simpler URL

Post by RussCraig »

Thanks for the info & link, David.

Ultimately here is what I'm trying to do: I'd like to rewrite this URL:

Code: Select all

https://xxx.xxx.xxx.com/
...or...
https://xxx.xxx.xxx.com/client
... to this:

Code: Select all

https://xxx.xxx.xxx.com/profoundui/start?pgm=RECLIB/PUIMENUCL&workstnid=PUIWEB##&suffixid=1
... where ## = a random number 1-99.

If anyone knows how to do this off the top of their head, please let me know. Either way I'm going to read up on mod_rewrite.

Thanks in advance!
There are 10 types of people in this world: Those who understand binary and those who don't.
RussCraig
Profound User
Posts: 62
Joined: Wed May 05, 2010 10:13 am
First Name: Russell
Last Name: Craig
Company Name: Applied Business Services
Phone: 252-482-7666
Address 1: 617 Soundside Rd
City: Edenton
State / Province: North Carolina
Zip / Postal Code: 27932
Country: United States
Location: Edenton, NC
Contact:

Re: Simpler URL

Post by RussCraig »

After looking into mod_alias and mod_rewrite, I found I could do this in httpd.conf:

Code: Select all

Redirect permanent /client https://xxx.xxx.xxx.com/profoundui/start?pgm=RECLIB/PUIMENUCL&workstnid=PUIWEB&suffixid=1
However, this only redirects to one fixed URL, which would limit us to 35 users. I've searched and searched, and could find no way to generate a random number inside the httpd.conf file. Would it be possible to use a ScriptAlias to point "/client" to a CGI program that would generate the unique URL and redirect the user to it? I have zero experience with CGI, which is why I'm asking.

Thanks!
There are 10 types of people in this world: Those who understand binary and those who don't.
RussCraig
Profound User
Posts: 62
Joined: Wed May 05, 2010 10:13 am
First Name: Russell
Last Name: Craig
Company Name: Applied Business Services
Phone: 252-482-7666
Address 1: 617 Soundside Rd
City: Edenton
State / Province: North Carolina
Zip / Postal Code: 27932
Country: United States
Location: Edenton, NC
Contact:

Re: Simpler URL

Post by RussCraig »

Just figured out a basic solution:

Using a ScriptAlias, I can point "/client" to a page that contains some Javascript that generates the unique URL and redirects the user to the new URL. This is adequate for what I was looking to do. However, ultimately what I want to do is mask the ProfoundUI info leaving just "https://xxx.xxx.xxx.com/client", if this is even possible (or legal!). Any ideas?

Thanks again!
There are 10 types of people in this world: Those who understand binary and those who don't.
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Simpler URL

Post by David »

I think the best bet for you here would be to have the CGI program that is the target of the /client alias start Profound UI for itself, rather than redirecting to the Profound UI start page.

If done this way, all that the user would see would be that ScriptAlias URL.

Have a look at the Profound UI start page at /www/profoundui/htdocs/profoundui/userdta/html/start.html

You can see that the page is just a blank page with a <div> element that has the id "pui" assigned to it. This is where the content will go.

You'll see that the page has an "onload" event that calls a JS function that starts PUI.

This function internally looks at the query string parameters and passes them along to PUI.

There is an alternate function pui.run() that you can use to pass the parameters along yourself rather than having it look at the query string.

For example, I was able to get it going like this:

Code: Select all


    window.onload = function() { pui.run({
	
		"program": "puisamples/menu001c",
		"workstnid": "PUIWEB",
		"suffixid": "1"

	}) };

There is one small problem with this approach, though. Unfortunatley it seems that the "workstnid" and "suffixid" parameters do not get passed through in the public version of Profound UI. This is due to a code packaging problem on our end.

For the next update to Profound UI, we will fix this so that those parameters get through.

Then, you could have your CGI program generate the random number, and then stick it onto the end of the "workstnid" parameter in the above code.

Keep an eye on updates to see when you can start using this.
RussCraig
Profound User
Posts: 62
Joined: Wed May 05, 2010 10:13 am
First Name: Russell
Last Name: Craig
Company Name: Applied Business Services
Phone: 252-482-7666
Address 1: 617 Soundside Rd
City: Edenton
State / Province: North Carolina
Zip / Postal Code: 27932
Country: United States
Location: Edenton, NC
Contact:

Re: Simpler URL

Post by RussCraig »

Awesome! That's the exact information I was looking for!

My current method works OK (ScriptAlias to a page w/JavaScript that generates and redirects to the unique URL). However, this still shows the ProfoundUI query parameters in the URL, and if their browser does not support redirection they have to click an extra link. Your method sounds MUCH nicer, keeping the ScriptAlias URL in the address bar (thus masking the query parameters) and avoiding redirection.

I will definitely keep my eye on the update page. Thanks again!
There are 10 types of people in this world: Those who understand binary and those who don't.
RussCraig
Profound User
Posts: 62
Joined: Wed May 05, 2010 10:13 am
First Name: Russell
Last Name: Craig
Company Name: Applied Business Services
Phone: 252-482-7666
Address 1: 617 Soundside Rd
City: Edenton
State / Province: North Carolina
Zip / Postal Code: 27932
Country: United States
Location: Edenton, NC
Contact:

Re: Simpler URL

Post by RussCraig »

Just upgraded to 2.2.6, and David's method works perfectly!

Thanks again!
-RC
There are 10 types of people in this world: Those who understand binary and those who don't.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests