Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: uri rewrite (WITH sub-domains) on a single page website (index.php) to process ALL pages and URL's based on MySQL data
    primarykey
    data
    text
    <p>I am building a website from scratch. EVERYTHING is in MySQL, all the code, meta data, js codes, CSS, body content, EVERYTHING. For that purpose, I created a class that renders an HTML page, based on variables provided by domain.com/index.php.</p> <p>I got insipid to do it this way, based on a blog I found a while back. It came with a full tutorial. Unfortunately, I can't find it anymore.</p> <p>Anyway, my "master" table, <code>URL's</code> is configured like so:</p> <pre><code>| subdomain | category | subcategory | page | extension | ----------------------------------------------------------------------- | | properties | houses | downtown-la | html | | properties | houses | downtown | | / | | ch | properties | houses | downtown-la | html | | jp | properties | houses | downtown-la | html | | jp.properties | houses | downtown | | / | | ch.properties | houses | downtown | | / | </code></pre> <p>Of course, the table has more fields like pageID., and I have other tables to define the content based on the language, page's title, description, keywords, etc.</p> <p>My goal is to:</p> <ol> <li>Have index.php process all uri/url requests into segments.</li> <li>Recognize if the user typed a sub domain/sub-subdomain or not. </li> <li>Pass those values to MySQL, to check if the page exists.</li> <li>Assign the findings to $status (1 for "page found" | 0 for "page not found") </li> <li>If the url/page exists, pass the page's id to $id, so the class can render the page (via MySQL)</li> </ol> <blockquote> <pre><code>$subdomain = 'properties'; $sub-subdomain = null; $domain = 'domain,com'; $category = 'houses'; $subcategory = 'downtown'; $ext = '/'; // url in browser: properties.domain.com/houses/downtown/ // some php code here to process url (because there's no folders. Only root/index.php) include('class-page.php'); switch ($status) { Case 1: $html =new page::create($id); echo $html; break; case 0: $html =new page::create(404); //php code to rewrite url as: www.domain.com/error/404.html echo $html; } </code></pre> </blockquote> <p>As you can see, I want to process ALL pages in index.php and make users think they are accessing a page in www.domain.com/category/subcategory/page.html</p> <p>The problem is, I so not know how to process url/uri in php not how to leave the url intact, without redirecting. I'd like to accomplish this feat with php and VERY little .htaccess (Or none preferably).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload