troubleshooting Question

htaccess and bootstrap file problem

Avatar of Marco Gasi
Marco GasiFlag for Spain asked on
PHP
4 Comments1 Solution1324 ViewsLast Modified:
Hi all, Experts. I need your help urgently.
I'm writing a web application and I'm setting up a bootstrap file following suggestions found on the web. The problem seems to be in the htaccess: or it sends me to the index.php (bootstrap code) and not to the desired page, or it send me to the desired page but bootstrap code is not executed.
Please, give me the trick!

This is is my bootstrap code in index.php
<?php
session_start();
//define our status constant: uncomment wanted option
//define('STATUS', 'production');
define('STATUS', 'developement');

//check what status we have
switch (STATUS) {
    case 'production': {
        ini_set('display_errors', 'Off');
        //and other specific includes, commands, etc.
    }
    break;
    case 'developement': {
        ini_set('display_errors', 'On');
        error_reporting(E_ALL);
    }
    break;
}

//let's set up a root path constant
define('ROOT', getcwd() . DIRECTORY_SEPARATOR);
//define the includes and config folders
define('INCLUDES', ROOT . 'includes' . DIRECTORY_SEPARATOR);
define('CONFIG', ROOT . 'config' . DIRECTORY_SEPARATOR);
define('CLASSES', ROOT . 'classes' . DIRECTORY_SEPARATOR);


//load in the main configuration file
require_once(CONFIG . 'config.php');

This is the required config.php
date_default_timezone_set('Europe/Rome');
require_once (CLASSES . 'mgUserManager.php');
require_once (CLASSES . 'mgUploader.php');
require_once (CLASSES . 'mgSearchPlaces.php');
require_once (CLASSES . 'mgSearchResult.php');
require_once (CLASSES . 'mgExceptions.php');
require_once (INCLUDES . 'functions.php');

And these two snippets are the two htaccess tried: the first one redirect to index.php:
  RewriteEngine on
  RewriteBase /
  RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php
  php_flag magic_quotes_gpc off

The second leads me to the desired page but without having initialization:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

I'll be very grateful to everyone for any help

Cheers
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros