1

What handles the disabling of the extension? Is it APACHE or the PHP install? How would one go about configuring the web server where the .php extension is not required? Is there an option that would make both www.example.com/page.php and www.example.com/page work as the URL?

6 Answers 6

8

It's URL rewriting through Apache: http://www.addedbytes.com/apache/url-rewriting-for-beginners/

Sign up to request clarification or add additional context in comments.

Comments

4

Apache also has a setting called MultiViews that will serve domain.com/index.* as domain.com/index, domain.com/example.* as domain.com/example, etc.

I've occasionally run into issues where MultiViews beats out mod_rewrite rules, so I tend to turn it off.

1 Comment

+1 MultiViews should definitely be turned off if you are to use mod_rewrite, otherwise you're guaranteed a headache.
3

Check out some articles from A List Apart on this topic: You use Apache (in your case) to setup ReWriteRule's and then you have PHP parse the url to fetch the correct information. (again, in your case. You can do this with many languages and http servers)

http://www.alistapart.com/articles/succeed/

http://www.alistapart.com/articles/urls/

Comments

2

brianreavis is correct. Here's an example for your .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Comments

1

I just throw it all at PHP and parse it however I want in there:

.htaccess

RewriteEngine On
RewriteRule !\.(js|ico|gif|jpg|png|css)$ @frontend.php

Comments

1

I use this in my .htaccess

<Files ~ "^[^.]+$">
ForceType application/x-httpd-php5
</Files>

That way I can remove all extensions (.php) from my files, and it will still work.

I use $_SERVER['PATH_INFO'] to retrieve the remainder of the path as parameters. E.g. /page/param1/param2 where page is an actual php file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.