Categories
Uncategorized

Slim PHP Route Does Not Appear To Be Working, Always Chooses / Route

Most people probably run Slim PHP the way it was intended.

By adding a .htaccess file into your directory and letting it do it’s magic thing. However, I have complete access to our server, and choose not to allow .htaccess files. I instead put all of my apache mod_rewrite statements into my apache config files.

However, I just found out that if you are running your Rewrite’s through your <VirtualHost> tags, then one of your server variables may be incorrect. I am not sure if this is Apache’s fault, or PHP’s. However, a simple fix is just set it yourself.

At the top of your PHP file, put the following.

$_SERVER[‘SCRIPT_NAME’] = ‘/RELATIVE_PATH_TO_YOUR_SLIM_APP_FILE.php’;

most people would probably use the following.

$_SERVER[‘SCRIPT_NAME’] = ‘/index.php’;

Leave a Reply

Your email address will not be published. Required fields are marked *