Page 1 of 1

How to hide file extension?

Posted: Sat Jun 20, 2009 12:42 pm
by gimpact
Hello,

I am new to php. I was going through this tutorial, can some please help me to understand this tutorial better?

Here is the link to my tutorial http://www.easymodrewrite.com/example-extensions

What i dont understand is, how do i use this in html forms. Lets say i have a form for submission to login.php. what should i write in the form? some thing like this

Code: Select all

<forms action = http://www.site.com/login></form>


OR in a case like where i am sending values through url, what should i type in the url

Code: Select all

header("Location:http://www.site.com/error?info=DatabaseConnectionNULL ");
Thank you

Re: How to hide file extension?

Posted: Sat Jun 20, 2009 1:03 pm
by Eric!
I assume you are modifying your .htaccess to allow .php files to be accesed without showing the .php Is that right?

You might try something simpler where you can just tell apache how to run a file without an extention.

Code: Select all

<Files login>
ForceType application/x-httpd-php
</Files>
Then apache always serves 'login' as php. No questions about how to acccess it either.

Re: How to hide file extension?

Posted: Sat Jun 20, 2009 5:41 pm
by requinix
No offense, Eric, but I absolutely hate having files without an extension. What are they supposed to be? HTML? PHP? You can't know unless you open up each one. And when you do, there's no extension for the editor to guess how to display the file.

Apache has a much nicer solution.

Code: Select all

Options +MultiViews
If you request /login and it doesn't exist, Apache will look to serve any login.* file.

Re: How to hide file extension?

Posted: Sat Jun 20, 2009 6:26 pm
by Eric!
Personally I'm not partial to extentions one way or another. How does it show up in the url? Could I still do something like

http://www.blahblah.com/download/user=me/filename.zip

Where download.php is the actual script and the rest I can parse inside the script? This works with the force file thing.

Re: How to hide file extension?

Posted: Sat Jun 20, 2009 8:28 pm
by gimpact
tasairis wrote:No offense, Eric, but I absolutely hate having files without an extension. What are they supposed to be? HTML? PHP? You can't know unless you open up each one. And when you do, there's no extension for the editor to guess how to display the file.
Well, I began paying attention to this when I noticed that most of the major sites such as google, ebay no longer use any file extension. So, i guess there must be some exceptionally good thing about this, which I dont know or may be, they use this to cover some thing which is undercover :-),

Re: How to hide file extension?

Posted: Sat Jun 20, 2009 9:44 pm
by requinix
Apache will route requests like it normally would.

Code: Select all

http://www.blahblah.com/download/user=me/filename.zip
First comes rewrite rules, aliases, etc. Then it tries serving /download (if it can't find "download" then it looks for "download.(set of file extensions Apache is aware of)") then /download/user=me, then /download/user=me/filename.zip.

Not having the extension in the URL makes it look cleaner. People not familiar with computers can remember "posting" as an action and not "posting.php" as a file. Blah blah blah other stuff.