• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3779
  • Last Modified:

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

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
BibMorano
Asked:
BibMorano
  • 3
  • 3
1 Solution
 
kalosiCommented:
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
 
robsmartCommented:
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
 
BibMoranoAuthor Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
robsmartCommented:
0
 
robsmartCommented:
------------------------------------------------------------------------------------------------------------------------
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
 
BibMoranoAuthor Commented:
hey I wanted to split points with the 2 of you ...

it was simple on the old site, but now ??
0
 
BibMoranoAuthor Commented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now