0

I have two types of extension page of php first is .php and the second is .php3.

I am using this code which is removing .php3 type but also want to remove .php

RewriteOptions inherit
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php3 [NC,L]
Joe
  • 4,877
  • 5
  • 30
  • 51
Atif
  • 41
  • 7
  • 2
    Instead of investing into changing the optics of your URL you should start _now_ to migrate to current versions. PHP3 is a _major_ security risk for your system and your data. – arkascha Jan 09 '17 at 18:59
  • i do not have any security issue, this is a simple small business project – Atif Jan 09 '17 at 19:01
  • 2
    if you actually **believe** you don't have a security issue, then you have a security issue **by definition**. PHP3 is over 16 years old. i completely agree with arkascha, you should upgrade **now** – Franz Gleichmann Jan 09 '17 at 19:02
  • `The last PHP 3 release (3.0.18) was made on October 20, 2000.` http://php.net/manual/php3.php well, if you think, that using a system that is made 16 years ago is safe... You should listen to others – Danielius Jan 09 '17 at 19:03
  • 2
    It may come off as rude the way this is being stated but what you have by nature is a security concern. Is this outward facing to clients? Do they give you data should be housed securely? Do you have other systems connected to this network? Do employees access this system with the computers? If yes then you are exposing all of this to potential disaster. No maybe not target level but I do banking at work and if it is breached sure shootin Identity theft could happen. – nerdlyist Jan 09 '17 at 19:15
  • 1
    Possible duplicate of [Remove .php extension with .htaccess](http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – nerdlyist Jan 09 '17 at 19:27
  • the whole page contain html codes, i am using just include_once php tag therefore i am using .php3 extension and want to remove it through .htaccess – Atif Jan 09 '17 at 19:29
  • Okay. Before that, let me know what version of PHP you're really using now? I ask this because you can also execute PHP script with the extension `php3` even when you have other PHP versions like 5.3 or 5.5 installed. So, you're really using PHP 3 at the moment? – Wolverine Jan 09 '17 at 19:33
  • That's right. I have also believed you must had been using version 5 onward. I believe few people assumed you were really using PHP 3. – Wolverine Jan 09 '17 at 19:35
  • Let me be clear of your question first. You pass an URL like `http://localhost/index` that would call `index.php` or `index.php3` based on the conditions in the `.htaccess`. Right? – Wolverine Jan 09 '17 at 19:45
  • http://localhost/index it will call index.php i have link which contain .php3 extension i wan when someone click on that link so .php3 extension .htaccess will remove it – Atif Jan 09 '17 at 19:49
  • If someone enters `index` with extension `.php3` like `index.php3`, the extension `.php3` will be removed and navigated to `http://localhost/index`? – Wolverine Jan 09 '17 at 19:53

2 Answers2

0

i got my answer by testing, one its working.

RewriteOptions inherit
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php3 [NC,L]
Atif
  • 41
  • 7
0
Options -MultiViews

RewriteEngine On

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

RewriteCond %{REQUEST_FILENAME}.php3 -f
RewriteRule ^([^\.]+)$ $1.php3 [QSA,NC,L]

Hope it helps!

Wolverine
  • 1,712
  • 1
  • 15
  • 18