Solved

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

Posted on 2003-10-23
7
3,770 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 1

Expert Comment

by:robsmart
Comment Utility
------------------------------------------------------------------------------------------------------------------------
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

11 Experts available now in Live!

Get 1:1 Help Now