RewriteEngine On
RewriteRule ^([a-zA-Z._-]+)$ system/application/controllers/$1 [L]
The only things I can see wrong with this are:
The - really should be the first character in the range definition but, as the last character, it should not be causing any problem.
Is the system/application/controllers directory in the website (in your DocumentRoot)?
If so, as I suspect, then there is likely a problem with your host’s configuration. To test it, change the [L] to [R=301,L] and see if the expected redirection has been made (and displayed).
Of course, you do need to confirm Apache 2.x as well as the fact that this mod_rewrite code is in your DocumentRoot.
But if i type in index.php at the end of the URL above it will show the redirect correctly (it appends to the html root 404 error URL) – This is okay, it will work normally and redirect if i turn the 301,L back to L
.htaccess with the rewrite code is in the /beta/ folder (thats all thats in .htaccess)
and my SERVER_SOFTWARE Apache/2.0.54
I’m not sure how much i can tweak Apache on a GRID Host but i can always email them
If beta/ is givnig a 404 but beta/index.php isn’t, then the DirectoryIndex for the beta directory does not include the index.php script. In that directory, look for a DirectoryIndex statement. If not there, go up to your DocumentRoot and enter (in your .htaccess):
DirectoryIndex index.php {whatever else that may be there separated by spaces, e.g., index.html, index.htm}
The weird thing is I tried that before and it actually loads the physical index.php file – yet doesn’t redirect it. I can run PHP in the blank index.php file (LOL).
So I popped this into the index.php and it’s behaving now:
<?php
ob_start();
if (basename($_SERVER['REQUEST_URI']) !== 'index.php')
{
header('location: index.php');
}
/*
This file is intended to be empty.
Removing this will cause the mod_rewrite to not default to an index page.
*/
ob_end_flush();
?>