thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Video 49 - URL Not Found Error #204

Closed ozyedi closed 2 years ago

ozyedi commented 7 years ago

Hi, i'm following your series. And need help,

In video 49, after .htacces file added to server, it gives me url not found error when i'm typing home after my url. i've checked all my codes 3 times, exactly same. Also my slug for my homepage is home. I'm using apache server on my laptop. I've also create Web.config file, readed other issues and tryin' that for solution, but not helping.

Here is my codes:

.htaccess file (its in same place with index.php)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

sandbox.php

<?php

function get_path(){
    $path=array();
    if(isset($_SERVER['REQUEST_URI'])){
        $request_path=explode('?',$_SERVER['REQUEST_URI']);
        $path['base']=rtrim(dirname($_SERVER['SCRIPT_NAME']),'\/');
        $path['call_utf8']=substr(urldecode($request_path[0]),strlen($path['base'])+1);
        $path['call']=utf8_decode($path['call_utf8']);
        if($path['call']==basename($_SERVER['PHP_SELF'])){
            $path['call']='';
        }
        $path['call_parts']=explode('/', $path['call']);
        if(array_key_exists(1,$request_path)){
            $path['query_utf8']=urldecode($request_path[1]);
            $path['query']=utf8_decode(urldecode($request_path[1]));
            $vars=explode('&',$path['query']);
            foreach($vars as $var){
                $t=explode('=',$var);
                if(array_key_exists(1,$t)){
                    $path['query_vars'][$t[0]]=$t[1];
                }
            }
        }
    }
return $path;
}

?>

setup.php

<?php

// Setup File:
error_reporting(0);

# Database Connection:
include ('config/connection.php');

# Constans:
DEFINE('D_TEMPLATE','template');

# Functions:
include ('functions/sandbox.php');
include ('functions/data.php');
include ('functions/template.php');

# Site Setup:
$debug = data_setting_value($dbc, 'debug-status');

$path = get_path();

$site_title = 'AtomCMS 2.0';

if(isset($_GET['page'])){

    $pageid = $_GET['page'];

}else{

    $pageid = 'home';

}

# Page Setup:
$page = data_page($dbc, $pageid);
?>

debug.php

<div id="console-debug">

    <?php

    $all_vars = get_defined_vars();

    ?>
    <?php // print_r($all_vars); ?>

    <h1>Path Array</h1>

    <pre>
        <?php print_r($path); ?>
    </pre>

    <h1>GET</h1>

    <pre>
        <?php print_r($_GET); ?>
    </pre>

    <h1>POST</h1>

    <pre>
        <?php print_r($_POST); ?>
    </pre>

    <h1>Page Array</h1>

    <pre>
        <?php print_r($page); ?>
    </pre>
</div>

Web.config file (same place with .htaccess and index.php)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
creptor commented 7 years ago

Check this comment, in there I explain how to work with IIS servers (they use apache too (kind of))

https://github.com/thedigicraft/Atom.CMS/issues/163#issuecomment-187409867

PLEASE replace your files (.htaccess and web.config) with those lines of code before continuing (the web.config just needs to be added, do not remove everything), your page should work then

this is how is supposed to look the web.config file after you have edit it -> https://github.com/thedigicraft/Atom.CMS/issues/163#issuecomment-187422820

[ it can be more, or less extensive, just make sure that this https://github.com/thedigicraft/Atom.CMS/issues/163#issuecomment-187409867 is in there in the correct position]