1

I'm trying to remove the extension from my PHP page.

For an example, www.mywebsite.com/verification.php

I want people be able to verify from www.mywebsite.com/verification.

My code:

<?php session_start(); ?>
!DOCTYPE html
html lang="en"
head>

meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

3 Answers3

7

According to this website:

Change your .htaccess file like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

You can do something similar, with the .html extension, except you change the last line to:

RewriteRule ^([^\.]+)$ $1.html [NC,L]

If you don't have a .htaccess file, do what @Cagy79 said:

You could make a directory /verification/ and put your script in an index.php.

In this way a user can go to www.yoursite/verification/ without the need of adding the index.php part

Community
  • 1
  • 1
Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88
4

You could make a directory /verification/ and put your script in an index.php.

In this way a user can go to www.mywebsite.com/verification/ without the need of adding the index.php part.

(Also, this can be done when you can't edit .htaccess files or when not on Apache)

Cagy79
  • 1,610
  • 1
  • 19
  • 25
2

Additionally you can use these two options mentioned in the PHP manual security section

  1. You can set expose_php to off in your php.ini file. Then no information about running PHP on your server will be sent in the header.

  2. You can use a .htaccess file option to obscure the filename. Available options that are mentioned are:

Make PHP code look like other code types

AddType application/x-httpd-php .asp .py .pl

Make PHP code look like unknown types

AddType application/x-httpd-php .bop .foo .133t

Make all PHP code look like HTML

AddType application/x-httpd-php .htm .html

The last method is not recommended, because all HTML files will run through the PHP interpreter, even if this is not necessary.

Philipp Palmtag
  • 1,310
  • 2
  • 16
  • 18