for instance if a page name is request.php
I should be able to request the page http://domain.com/request
I'm wondering how can it be done? .htaccess? or some other measure, please give an example in case.
Please advise.
for instance if a page name is request.php
I should be able to request the page http://domain.com/request
I'm wondering how can it be done? .htaccess? or some other measure, please give an example in case.
Please advise.
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php[\s?] [NC]
RewriteRule ^ %1 [R=301,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
RewriteRule ^(.*)$ index.php?query=$1 [L]
You can enable this behavior globally in the server with MultiView and mod_negotiation:
http://httpd.apache.org/docs/2.2/mod/mod_negotiation.html
In centos (with plesk) you should edit:
/etc/apache2/sites-enabled/000-default
in Debian and Ubuntu systems should be:
/etc/httpd/sites-enabled/000-default