Forum Moderators: phranque
RewriteEngine On
RewriteBase /
RewriteRule .* index2.php
<?php
echo "hiiii";
class Foo {
static public function test($classname)
{
if(preg_match('/\\\\/', $classname))
{
$path = str_replace('\\', '/', $classname);
}
else
{
$path = str_replace('_', '/', $classname);
}
if (is_readable($path.".php"))
{
require_once $path .".php";
}
}
}
spl_autoload_register('\Foo::test');
\controller\Controller::run();
?>
RewriteEngine On
RewriteBase /
This is garbage
RewriteRule .* index2.php
http://example.com/foo/bar/quux/ with a trailing slash, I would be redirected to http://example.com/MyProject/foo/bar/quux - removing slash and adding MyProject/ and if I requested http://example.com/MyProject/foo/bar/quux/ with a trailing slash, I would be redirected to http://example.com/MyProject/MyProject/foo/bar/quux - removing slash and adding MyProject/ again. # comment before each block of code explaining in plain English what the block of code does. http://example.com/foo/bar/quux?id=456&page=2 with parameters or are they just like http://example.com/foo/bar/quux without parameters? While I see what you're saying and you're making it seem easy
I've just realised where one of your initial problems might have been. I believe that you've got this .htaccess file in the /MyProject/ folder rather than in the site root. You are therefore now aware that "MyProject/" is removed from the path before the path is presented to RewriteRule for evaluation. In Apache speak 'the path is localised "per directory"'. Of course you have added that item back in within your redirect.
Finally, do you actually need the QSA flag? Are valid requested URLs ever in the form http://example.com/foo/bar/quux?id=456&page=2 with parameters or are they just like http://example.com/foo/bar/quux without parameters?
Hopefully, you now understand your code a bit better, and it is your code not mine. You wrote it. The important stuff is the difference between URLs and filepaths and the difference between redirects and rewrites. Once you get that there's no looking back.
This thread also underlines the WebmasterWorld forum principle. We help you debug your code, code you wrote. We don't write your code. This way you learn much more. :)