By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,493 Members | 3,090 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,493 IT Pros & Developers. It's quick & easy.

Avoiding empty parameters in URL and more

P: n/a
Is there any way I can keep those URLs...
www.example.com/?q=hello&type=

from appearing? Let's say I have a form with a select-options box.
Along with a single text-input. Now if "q" is the name of the input box
and "type" is the name of the select-box, I also have a default for
type (which is empty and does nothing). Do I need to have htaccess
redirects to clean above URL to this one:

www.example.com/?q=hello

On a side-note: is there anything bad about /?q=hello, where the longer
version would be /index.php?q=hello ? I do not want to code my
scripting file extension into the URL. I want the URl to live longer
than my choice of scripting language, besides I want it to be as short
and easy-to-read (and pass on) as possible. Any ideas?
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Philipp Lenssen" <in**@outer-court.com> wrote:
Is there any way I can keep those URLs...
www.example.com/?q=hello&type=

from appearing?
Ummm... stop creating them? But what is your problem with them?
Let's say I have a form with a select-options box.
Along with a single text-input. Now if "q" is the name of the input
box and "type" is the name of the select-box, I also have a default
for type (which is empty and does nothing).
Yes, what is the problem?
Do I need to have
htaccess redirects to clean above URL to this one:

www.example.com/?q=hello
Why would you need to do that? Your server-side form handler should
simply deal with what it gets, and be prepared to literally anything.
It can check for a field named "q" and simply ignore anything else, if
you like.
On a side-note: is there anything bad about /?q=hello, where the
longer version would be /index.php?q=hello ?


Of course not, as long as your server deals with it. If it internally
treats http://www.example.com/ as mapped to
http://www.example.com/index.php, everything works fine.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #2

P: n/a
On 6 Feb 2004 15:01:37 GMT, "Philipp Lenssen" <in**@outer-court.com>
wrote:
Is there any way I can keep those URLs...
www.example.com/?q=hello&type=
from appearing?


No. Even if you stop creating them, there's nothing to stop me (as a
user) from hand-typing them into my browser.

Make your server deal with them. Do something sensible if it's given
garbage.

This is one instance of the principle "Be tight when producing data,
be loose when accepting it". It works equally well when applied to
URLs.

--
Die Gotterspammerung - Junkmail of the Gods
Jul 20 '05 #3

P: n/a
Jukka K. Korpela wrote:
"Philipp Lenssen" <in**@outer-court.com> wrote:
Is there any way I can keep those URLs...
www.example.com/?q=hello&type=

from appearing?


Ummm... stop creating them? But what is your problem with them?


The problem is minor: I want to have a highly readable URL and above
could be slightly more readable.

E.g. the following URL is a Google Groups search for "test":

<http://groups.google.com/groups?hl=e...-8&safe=off&q=
test&sa=N&tab=wg>

It looks fine, but when I copy it to link to it (on my website, in
email, newsgroup) I don't feel comfortable because it seems to contain
garbage, and possibly garbage exposing something like my user-id or
settings or whatever.

E.g. clicking on the first link I am referred to the even worse:

<http://groups.google.com/groups?q=te...&oe=UTF-8&safe
=off&selm=fr.chartes.test-1075935661.719681%40calva.glou.org&rnum=1>

So I'm just thinking about how to make my URLs as simple as possible.
That's all.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #4

P: n/a
Andy Dingley wrote:
On 6 Feb 2004 15:01:37 GMT, "Philipp Lenssen" <in**@outer-court.com>
wrote:
Is there any way I can keep those URLs...
www.example.com/?q=hello&type=
from appearing?


No. Even if you stop creating them, there's nothing to stop me (as a
user) from hand-typing them into my browser.

Make your server deal with them. Do something sensible if it's given
garbage.


I don't have problems accepting the data, in fact it'd be just empty
anyway, I just want the URL to be as simple as possible for users
copying it. Often I create the following thing from above:

www.example.com/hellp/type-x/

So I find this easier to get for users, search engines, etc.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #5

P: n/a
In article <c0*************@ID-203055.news.uni-berlin.de>,
"Philipp Lenssen" <in**@outer-court.com> wrote:
Is there any way I can keep those URLs...
www.example.com/?q=hello&type=

from appearing?
Ummm... stop creating them? But what is your problem with them?


The problem is minor: I want to have a highly readable URL and above
could be slightly more readable.

E.g. the following URL is a Google Groups search for "test":

<http://groups.google.com/groups?hl=e...-8&safe=off&q=
test&sa=N&tab=wg>


Can be rewritten as <http://groups.google.com/groups?q=test>.

It looks fine, but when I copy it to link to it (on my website, in
email, newsgroup) I don't feel comfortable because it seems to contain
garbage, and possibly garbage exposing something like my user-id or
settings or whatever.

E.g. clicking on the first link I am referred to the even worse:

<http://groups.google.com/groups?q=te...&oe=UTF-8&safe
=off&selm=fr.chartes.test-1075935661.719681%40calva.glou.org&rnum=1>

So I'm just thinking about how to make my URLs as simple as possible.
That's all.


Maybe this will spark inspiration:
<http://www.alistapart.com/articles/succeed/>

--
Kris
<kr*******@xs4all.netherlands> (nl)
<http://www.cinnamon.nl/>
Jul 20 '05 #6

P: n/a
Kris wrote:
In article <c0*************@ID-203055.news.uni-berlin.de>,
"Philipp Lenssen" <in**@outer-court.com> wrote:

E.g. the following URL is a Google Groups search for "test":

<http://groups.google.com/groups?hl=e...=UTF-8&safe=of
f&q= test&sa=N&tab=wg>


Can be rewritten as <http://groups.google.com/groups?q=test>.


I know. You know. But most people either don't know or are too lazy.

Maybe this will spark inspiration:
<http://www.alistapart.com/articles/succeed/>


Thanks!

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.