Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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,778 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
Industry Leaders: 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!

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

618 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