Solved

How to hide .php file extension like in "http://www.google.ca/search?q=string"

Posted on 2003-10-23
7
3,771 Views
Last Modified: 2010-03-04
I've read a lot of article on the subject, saying that I should add some directives to my httpd.conf ,  or add lines to a .htaccess file, but I'd like to know how some sites like Yahoo! and Google do work with hiding file extension...

http://www.google.ca/search?q=g   ->  "search" has no file extension, and can still receive arguments
http://hockey.fantasysports.yahoo.com/hockey/show?page=roster   ->  "page" has no extension

How do those sites work with getting rid of file extensions ?

I don't want the webserver to interpret my .html files as .php, I just want to have some .php files written with no extension, and calling them in my browser with no extension.

I could also put the ForceType directive in my httpd.conf:

<Location /home>
     ForceType application/x-httpd-php
</Location>
and then having a "home" php file with no extension, but would I have to put a <location> tag for all of my files ?

I'd like to ear your opinions on how Yahoo! and Google work to hide their extensions. Their files are interpreted correctly by the webserver and are probably named without the extension. Anyways, thx a lot :)
0
Comment
Question by:BibMorano
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:kalosi
ID: 9612594
Probably google usues a CGI script written in C which has no extension by default.
I don't know weather this is a good idea if you still want to hide the extensions I would do it on location base.

david
0
 
LVL 1

Accepted Solution

by:
robsmart earned 400 total points
ID: 9612996
For the following ....

------------------------------------------------------------------------------------------------------------------------
http://www.google.ca/search?q=g   ->  "search" has no file extension, and can still receive arguments
------------------------------------------------------------------------------------------------------------------------

You can add an alias to the apache httpd.conf
Alias /search "C:\apps\webroot\search.php"

And for ...
------------------------------------------------------------------------------------------------------------------------
http://hockey.fantasysports.yahoo.com/hockey/show?page=roster   ->  "page" has no extension
------------------------------------------------------------------------------------------------------------------------

show.php may be an index type page that can include other php pages, the following code would do this

-----------------------------------------------------------------------
if(isset($HTTP_GET_VARS['page']))
      $page = $HTTP_GET_VARS['page'];

include $page.".php";
------------------------------------------------------------------------

if you were using this you would obviously need some kind of security check to
ensure that the user is allowed to access the page you are including.
This could be an array of page names that you want to allow access to.
0
 

Author Comment

by:BibMorano
ID: 9613886
for:
------------------------------------------------------------------------------------------------------------------------
http://hockey.fantasysports.yahoo.com/hockey/show?page=roster   ->  "page" has no extension
------------------------------------------------------------------------------------------------------------------------

I meant "show" has no extension...  lol;  my bad
i know how to handle the "page" GET_VAR, but "show" don't have extension

Do you know what language Yahoo! uses ?  php  or  cgi ?  anyways, one or another, it's the same...
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 1

Expert Comment

by:robsmart
ID: 9613995
0
 
LVL 1

Expert Comment

by:robsmart
ID: 9614006
------------------------------------------------------------------------------------------------------------------------
http://hockey.fantasysports.yahoo.com/hockey/show?page=roster   ->  "page" has no extension
------------------------------------------------------------------------------------------------------------------------

this can be done the same way as the first with an alias in Apache httpd.conf (but you probably guessed that ;)

Alias /hockey/show "C:\apps\webroot\hockey\show.php"


Yahoo does use PHP http://public.yahoo.com/~radwin/talks/yahoo-phpcon2002.htm
0
 

Author Comment

by:BibMorano
ID: 9615198
hey I wanted to split points with the 2 of you ...

it was simple on the old site, but now ??
0
 

Author Comment

by:BibMorano
ID: 9616452
Adding an Alias in the httpd.conf is a good idea !

but, you'll find me annoying, but let's say I write this line:

Alias /test/index "/test/index.php"

and then I reach it via http in my browser:

if I write:
http://hostname/test/index  ->  it'll work, no prob :)

but if I write:
http://hostname/test/index.php  ->  it also works !

How then does Yahoo! exactly work ?  if I go to a page without extension, it will load. And if I add .php to it, it will not !
do you think that Yahoo! names their file with a weird extension (like .kyz), so that I would have to write the correct extension in order to also view the file ?  so since we don't know the extension, we can't access Yahoo!'s files by typing the extension ?

does my theory would make sense ?


Is there a way to add an alias like I wrote:
Alias /test/index "/test/index.php"

so that a user could access it by typing "http://hostname/test/index", but not "http://hostname/test/index.php" ?

the Yahoo! file extension mystery really freaks me out
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now