Is it possible to configure Apache in order not to show a file extension?
For example: Say I have domain.com/page.php
but want to have domain.com/page
as the url.
Any Ideas?
The . html extension can be easily removed by editing the . htaccess file.
If they are used trough include or require , any extension will work.
php file extension refers to the name of a file with a PHP script or source code that has a ". PHP" extension at the end of it. It's similar to a Word file with a . doc file extension.
Put this is your .htaccess file
#turn on url rewriting RewriteEngine on #remove the need for .php extention RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php
This allows you to access .php files without the extension, so your links should read
href="/somepage"
and this will direct to
href="/somepage.php"
There is also MultiViews
as a vhost or .htaccess configuration option. See http://httpd.apache.org/docs/2.2/content-negotiation.html#multiviews
From that page:
The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With