?
Solved

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

Posted on 2003-10-23
7
Medium Priority
?
3,777 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1200 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

765 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