user3133351
user3133351

Reputation:

PHP files without extensions

Is it bad to use:

ForceType application/x-httpd-php

and to save files without a file extention (e.g. index instead of index.php)? The intention is to hide/remove .php from the URL and to stop users from manually putting e.g. /example.php.

Upvotes: 0

Views: 185

Answers (3)

Jessica
Jessica

Reputation: 7005

Yes. Yes it is bad.

The right way to do that is by using mod_rewrite and .htaccess files.

Upvotes: 1

MisterKatiyar
MisterKatiyar

Reputation: 21

Its not good practice to change extension as it will need configuration for web server each time and so its a portability issue.

You should use .htaccess directives to setup any level of customization. And in best practice you can route all requests to index.php to avoid direct access of php files.

Upvotes: 0

Dadou
Dadou

Reputation: 1008

To remove the file extension, add this to the .htaccess :

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

change .php to the proper file extension

new link :

<a href="file">link text</a>

Edit :

Save your files as index.php, about.php, and so on

Upvotes: 2

Related Questions