Reputation: 4073
some time ago I use a small php mvc framework. This framework works using the .htaccess file. In the .htaccess I use some rules to take the url and pass it through parameters at my index.php file, like this:
php_flag display_errors on
php_value error_reporting 9999
RewriteEngine On
RewriteBase /fba/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Later in my index.php I use the url parameter to split the url and instantiate the Controller and the method to invoke. For example if the url is something like myserver.com/User/getAll
this will instantiate the controller User and invocate the getAll method. But now I'm working in a server that has disabled the .htaccess file, and I can't change it. There is some alternative to the use of the .htaccess file, do the splitting of the url in some php file maybe?
If you want to see the full code of this framework you can check here
Upvotes: 0
Views: 439
Reputation: 828
Not sure about your actual architecture and needs, but alternative solution may be something like overwriting the routing:
<?php
if (isset($_GET['action'])) {
include 'controllers/' . check_filename($_GET['a']) . '.php';
}
if (isset($_GET['view'])) {
include 'views/'.check_filename($_GET['v']) . '.php';
}
?>
Upvotes: 1
Reputation: 1229
Well.. You could refer to the main index.php and add variables:
index.php?url=User-getAll
Keeping the links as they are, will not work, as the server does not know that you want all the links to refer to the index.php.
Upvotes: 0