.htaccess files not working and how to rename files using htaccess
I am using below script to hide file extension in my website.i got this script from net
Rew开发者_开发百科riteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
but this script is not working,its showing no error but its not hiding file extension ;can you tell me whats happening in this..i am new to this script..
and can you also tell me how to rename my php and show in url using htaccess(to prevent hacking)
(eg www.website.com/contact.php to www.website.com/Mycontact)
The provided code should work, if you type in www.site.com/contact do you arrive at www.site.com/contact.php?
To 'rename your php' you will have to make the .htaccess very specific like so:
RewriteRule ^Mycontact$ contact.php
Maybe it is better to do something along these lines:
RewriteRule ^(.*)$ loader.php?p=$1
And then have loader.php contain something like this code:
$pages = array();
$pages['Mycontact'] = 'contact.php';
if(isset($_GET['p']) && isset($pages[$_GET['p']]))
require $pages[$_GET['p']];
else // redirect to homepage
header('Location: http://www.site.com/');
Or with a switch
switch($_GET['p']){
case "Mycontact":
require 'contact.php';
break;
default:
header('Location: http://www.site.com/');
}
精彩评论