thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Part 49 - Using PHP to Handle a Clean URL #163

Open shicala opened 8 years ago

shicala commented 8 years ago

I have double checked what I put into my files matches the video I also compared it to the master files that are available. They appear identical....

my .htaccess = http://pastebin.com/Z2vYnmEp my setup.php = http://pastebin.com/spPgKWsr my debug.php = http://pastebin.com/jzbJHpRK my sandbox.php = http://pastebin.com/9bhjxxgn

I followed the video till timestamp 5:09 when it tells us to put /home at the end of the URL and shows the debug panel again with the new parsed info and the page loading just fine.

however when I put home at the end of MY url online all I get is a 404 error page.

my project site = http://shicala.com/AtomCMS/

please help :/ dunno what I missed

creptor commented 8 years ago

I see you're using a windows hosted... etc. Well IIS works different in some ways from apache, but everything in the configuration is kind of the same.

Now IIS 7 or above need a special file called Web.config , according to this, but I maybe can help you here.

First you should definitely check the IIS or server version of your host, if it's 7 or higher try the Web.config solution, if it isn't, then try with the .htaccess. You can use both if you're not sure of this.

IIS 7-

Filename: .htaccess Code:

RewriteBase /
ErrorDocument 404 /index.php
<IfModule mod_rewrite.c>
    RewriteEngine On
    Options -Indexes
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

IIS 7+

Filename: Web.config Code:

<rewrite>
    <rules>
        <rule name="rule 1I" stopProcessing="true">
            <match url="^index\.php$"  />
            <action type="Rewrite" url="/-"  />
        </rule>
        <rule name="rule 2I" stopProcessing="true">
            <match url="."  />
            <action type="Rewrite" url="//index.php"  />
        </rule>
    </rules>
</rewrite>

or

<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>

References: documentation, extra with IIS Manager, converter

creptor commented 8 years ago

Oh, and I think the version of IIS is 8, because in the error, the page title says IIS 8.0 Detailed error -. link

shicala commented 8 years ago

you are prob right about the IIS version, I do in fact use windows hosting, I bought windows hosting specifically cause of some forum software i use which is ASP based.

I tried with the web.config files you suggest above and now just loading the page in general i get

Config Error Configuration file '\?\e:\HostingSpaces\stickney\shicala.com\wwwroot\AtomCMS\web.config' does not contain a root tag Config File \?\e:\HostingSpaces\stickney\shicala.com\wwwroot\AtomCMS\web.config

I'm confused i've never used this file before so I really dont know what that means

creptor commented 8 years ago

Sorry I didn't explain correctly before. Those codes (for IIS 7+) are only the rules you should add to the default Web.config. A full Web.config file should be like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="true" />
        <rewrite>
            <rules>
                <rule name="rule 1I" stopProcessing="true">
                    <match url="^index\.php$"  />
                    <action type="Rewrite" url="/-"  />
                </rule>
                <rule name="rule 2I" stopProcessing="true">
                    <match url="."  />
                    <action type="Rewrite" url="//index.php"  />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

or

<?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>

(I have never done this, and I can't test it, but based on documentation it should work)

creptor commented 8 years ago

Try to remove the spaces, and replace them with tabs. To avoid the script from running into an error. (or vice versa, I don't know :c)

shicala commented 8 years ago

I wound up using

http://pastebin.com/FMiiLeS1

(you had an extra in there that wasnt closed)

and it looks like it is working now thankyou very much for your help

creptor commented 8 years ago

Nice :D , I just fixed the error. Nice I could help :P

shicala commented 8 years ago

I greatly appreciate it :)

shicala commented 8 years ago

I dont get the 'call' it talks about

Array ( [base] => /AtomCMS [call_utf8] => home [call] => [call_parts] => Array ( [0] => )

[query_utf8] => 
[query] => 
[query_vars] => Array
    (
        [] => 
    )

like the video shows I should, but least no 404

creptor commented 8 years ago

please create another issue if it's related to something else. :3

shicala commented 8 years ago

any thoughts why I'm not getting the full array ?

I don't know if it's related at all