php – Rewrite url not working, only blank screen-ThrowExceptions

Exception or error:

I’m trying to rewrite my urls to seo friendly url.

I would like to change:

product-bekijken?title=cbd-olie-van-renova

to:

product-bekijken/cbd-olie-van-renova

RewriteEngine on  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ /index.php [L,QSA]

# redirect "/product.php?title=..." to "/product-bekijken/..." to hide a directly accessed "ugly" url
RewriteCond %{THE_REQUEST} \s/product-bekijken\?title=(.+)\s [NC]
RewriteRule ^ /product-bekijken/%1? [R=301,L]

# internally rewrite "/product-bekijken/..." to "/product.php?title=..."
RewriteRule ^product-bekijken/(.+)$ /product-bekijken?title=$1 [L]

This is my View.php where i load the template assets and pages. in the view folder are the template page files

<!DOCTYPE html>
<html lang="nl">
    <body>
        <div id="preloder">
            <div class="loader"></div>
        </div>
        <?php include_once($CONFIG->get_templatesettings('TEMPLATE_ROOT') . '/includes/header.php'); ?>
        <?php include_once($CONFIG::get_templatesettings('TEMPLATE_ROOT') . '/views/' . $PAGE::get_page() ); ?>
        <?php include_once($CONFIG->get_templatesettings('TEMPLATE_ROOT') . '/includes/footer.php'); ?>
        <?php include_once($CONFIG->get_templatesettings('TEMPLATE_ROOT') . '/includes/scripts.php'); ?>
  </body>
</html>

It will redirect the url i want, but the page with only the header and footer, but the product view is blank.

Below is the display.class.php

class view{

    private static $page;

    public static function set_page(){

        //This is for developers
        //ini_set('display_errors', 'On');
        //error_reporting(E_ALL);

        //What page should be displayed.
        $file = strtok( basename($_SERVER["REQUEST_URI"]) , '?');
        switch($file){

            //Api access point
            case '':
                self::$page = 'index.php';
            break;

            case 'product-bekijken':
                self::$page = 'product.php';
            break;
            }
    }
    public static function get_page(){
        return self::$page;
    }
}
How to solve:

Leave a Reply

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