Skip to main content

Reply To: I need to use a file name other than index.php

ClassiBase classifieds script Forums General help I need to use a file name other than index.php Reply To: I need to use a file name other than index.php

#528 Reply

ClassiBase
Keymaster

Renaming index.php to any other filename like index2.php will not reduce load on your site because if visitor goes to yourdomain.com/index.php it will load site’s homepage, it will not give 404 error page. So yourdomain.com/index.php is same as yourdomain.com/ will load homepage of your site.

To restrict direct access to index.php use following snippet at the top of your sys/config.php file on line 2 just after opening php tag.

// restrict direct access to index.php
list($req_script, ) = explode('?', $_SERVER['REQUEST_URI']);
list(, $req_script_last) = explode('/', trim($req_script, '/'));
if($req_script_last == 'index.php')
{
	header('HTTP/1.0 404 Not Found');
	exit('index.php direct request formidden');
}

We suggest using this snippet on config file because on script update sys/config.php file will stay unchanged. Where index.php will be replaced with new version.

  • Classifieds Business Newsletter

    Get discounts and tips about growing your classifieds website.

    Subscribe