What Wiedmann meant was that there's no file called D:\xampp\htdocs\silencor\geral\.php.
In order to get a variable from the URL, you need to use $_GET[$variable_name]. So, for example, you'd use $_GET['lang'] to get the language variable, such as $lang=$_GET['lang'].
Also, to get the file the way you want would mean that anybody can get access to any .php file, even if that file is in your admin folder and you don't want just anybody to get access to it. As well, if your file doesn't exist, you're going to get errors like that.
I personally think that the best way to do something like this, if you don't want them to know that you're using PHP, is to configure your .htaccess file to say:
- Code: Select all
RewriteEngine On
RewriteRule .* index.php
Then, when you have people put in a URL, they can put something like:
http://site.com/file?lang=english.
Then, in your index.php file, do:
$question=strstr($_SERVER['REQUEST_URI'],'?');
$name=str_replace($question,"",$localhost);
$filename=strtolower(substr($name,1));
$language=$_GET[lang]uage;
This way, when you parse the URL, you get the name of the file. So, for instance:
http://website.com/blah?language=englishwould return $filename='blah' and $language='english'.
Obviously you wouldn't be able to access
http://website.com/index because then you'd have an infinite loop. So...You'd have to do something like:
- Code: Select all
if(!$filename)
{
$include='indexpage';
}
elseif(file_exists($filename) && $filename!='index')
{
$include='$filename';
}
else
{
$include='/path/to/error/page';
}
include($include);
This way, as well, if somebody tries to determine the existence of a given file via
http://validator.w3.org, he or she won't be able to determine the 404 error code.
Note: If you include any JavaScript, CSS, or image files, you'll need to test $filename for the presence of the extensions and then use header('application/javascript'), header('text/plain'), or header('image/' . $imagetype) [where $imagtype is the image extension] and then echo the file contents of the JS or CSS files, and then use
image functions for the image files.
This type of code is especially convenient for hiding JavaScript, CSS, and image direct-link views (such as
http://website.com/javascript.js or
http://website.com/image.png) when you research how to do that kind of coding. I do it with my site, so if you want to learn how, just PM me, and I'll tell ya.