I suppose you mean that you have a CodeIgniter installation in, for example, /foo/bar/my-ci-app
which has a .htaccess
file in it.
You also have a simple.php
residing in /foo/bar/simple.php
(outside of the framework). And now you want to remove the .php
extension from that simple.php
file, right?
Directives defined in an htaccess file are only effective upon their residing directory and its sub-directories. Since your simple.php
file is outside of CodeIgniter installation, that htaccess file is no use for you as its directives do not take effect backward.
You need another htaccess file residing beside your simple.php
file in foo/bar/.htaccess
. The rewrite rule you need to drop the php extension is as follows:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Just to be sure that these rules has no conflict with your
# codeigniter rewrite rules, we're gonna discard the following
# rewrite rule if the request uri contains its directory name.
RewriteCond %{REQUEST_URI} !my-ci-app
# If the corresponding php file exists
RewriteCond %{REQUEST_FILENAME}.php -f
# And the request uri does not contain a php file format,
# for example, whatever.php, rewrite the request to a file
# named as %{REQUEST_FILENAME} (simple in your case) and add
# a .php extension to it.
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
</IfModule>
## Results
# simple => simple.php
# example => example.php