Link to home
Start Free TrialLog in
Avatar of kumarjcet
kumarjcet

asked on

How to hide php extension using .htaccess in shared server

I have used the below code


RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule .+ %1.php [QSA,L]

still my i am not able to call the file without its extension ".php"
Avatar of Garry Glendown
Garry Glendown
Flag of Germany image

Does your rewrite engine work at all? Did you permit changing this in .htaccess in the global config?
Hope you don't mind me asking, why hide it at all? If you don't want to divulge the info that you are running PHP for security reasons - security by obscurity doesn't work ... ;)
Avatar of kumarjcet
kumarjcet

ASKER

yeah my rewrite engine is working when i try to  rewrite my website folders

RewriteRule ^admin/(.*) administrator/$1

this is working , when i hit admin... its mapping to administrator...

But in file scenario, it is not working... i wonder why it is not working...
I fixed your rule, here you go:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/$0.php -f
RewriteRule ^(.*)$      $1.php [L]

Open in new window

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

Open in new window

http://www.spencerdrager.com/2010/02/07/hide-php-extension-in-url-using-htaccess/
Its not working.But i found the issue.

Apache server version 1.3.34 is the culprit.

Its not understanding the regex rewrite

code.

Is there any way to implement url

rewriting for Apache server version 1.3.34?
please upgrade to 2.2.21, 1.3.34 has very security leaks
ASKER CERTIFIED SOLUTION
Avatar of xterm
xterm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial