filename without extension in URL query

G

Guest

If I have a search submit button, when I click submit button, it will
submit the form to search.asp for form processing. This will be the URL:
http://www.mycompany.com/search.asp?q=programming

But when I do search in google, search doesn't have any file extension.
How do they do that? I saw some site are like that too.
http://www.google.com/search?hl=en&q=programming&btnG=Google+Search

Please advise. thanks!!

If you're using Apache, look into the ScriptAlias directive. This
configuration option tells the webserver that everything under a certain
URL are to be handled by CGI (ie execute those files and send the result
to the browser). Most often, directories are listed, but individual files
can be specified.

HTH,
La'ie Techie
 
M

Michael Winter

(e-mail address removed) wrote:

[snip]
But when I do search in google, search doesn't have any file extension.
How do they do that? I saw some site are like that too.
http://www.google.com/search?hl=en&q=programming&btnG=Google+Search

With Apache, you can the MultiViews directory option and content
negotiation. If a given filename can't be found, the module will look
for files that begin with whatever name was specified.

Clearly, content negotiation is meant for choosing between multiple
options based on some criteria like media type or language, but it
still works with only one choice of file.

See <URL:http://httpd.apache.org/docs-2.0/content-negotiation.html>.

Mike
 
J

John Dunlop

Followups to c.l.php.
If I have a search submit button, when I click submit button, it will
submit the form to search.asp for form processing.
This will be the URL: http://www.mycompany.com/search.asp?q=programming

Not a terrible URI; in fact the only questionable part is
the '.asp', which you want to remove anyway.
But when I do search in google, search doesn't have any file extension.

As a rule, URI suffixes like '.asp' are redundant and serve
only to advance link rot, and so should not be present in
URIs. The exceptions are few and far between.
How do they do that?

No idea; if you really want to know how they do it, you'd
better ask them. There are various approaches, but with
Apache, your best bet is probably MultiViews, which you will
likely need to enable.

http://httpd.apache.org/docs/content-negotiation.html
 
D

Dani CS

If I have a search submit button, when I click submit button, it will
submit the form to search.asp for form processing.
This will be the URL: http://www.mycompany.com/search.asp?q=programming

But when I do search in google, search doesn't have any file extension.
How do they do that? I saw some site are like that too.
http://www.google.com/search?hl=en&q=programming&btnG=Google+Search

You want to check the Apache directive ForceType. I've set it up like
this in my .htaccess:

<FilesMatch "^([^\.]+)$">
ForceType application/x-httpd-php
</FilesMatch>

This way, any file without a dot in its name will be processed by the
PHP parser.

More info: http://us3.php.net/manual/en/security.hiding.php
 
C

Chris Smith

If I have a search submit button, when I click submit button, it will
submit the form to search.asp for form processing.
This will be the URL: http://www.mycompany.com/search.asp?q=programming

But when I do search in google, search doesn't have any file extension.
How do they do that? I saw some site are like that too.
http://www.google.com/search?hl=en&q=programming&btnG=Google+Search

Since you cross-posted this to a Java newsgroup as well, I'll give you
the answer in Java servlets. Followups set.

When you map a servlet to a URI, you do so with a <servlet-mapping>
element in WEB-INF/web.xml. That URI pattern can have a number of
different forms (including various uses of wildcards), but you can very
easily write:

<servlet-mapping>
<servlet-name>my_servlet</servlet-name>
<url-pattern>/search</url-pattern>
</servlet-mapping>

If you're using a JSP, then it's a little more complicated. In general,
though, JSPs should never be the direct targets of requests from
browsers. It's far more flexible to handle HTTP requests with a
servlet, and then use RequestDispatcher to forward to the appropriate
JSP file depending on how you wish to respond. That even leaves you the
flexibility to avoid a JSP entirely; for example, if you need to
generate an image, or build an extremely dynamic page programmatically
with Apache ECS, or something of that sort.

If you insist on using JSPs to handle browser requests directly, then
you would either need to add a servlet mapping for the JSP servlet to
web.xml (generally, the JSP servlet is called "jsp", but I'm not sure
off-hand whether that is specified or container-specific), or you could
use any of the same techniques mentioned by the PHP folks already, with
an Apache front-end.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
R

R. Rajesh Jeba Anbiah

If I have a search submit button, when I click submit button, it will
submit the form to search.asp for form processing.
This will be the URL: http://www.mycompany.com/search.asp?q=programming

But when I do search in google, search doesn't have any file extension.
How do they do that? I saw some site are like that too.
http://www.google.com/search?hl=en&q=programming&btnG=Google+Search

These previous discussions may help you some.

1.
<http://groups.google.com/[email protected]>
2.
<http://groups.google.com/[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top