Friday, November 30, 2012

Re: IIS 7, CakePHP 2.2.3 and the Blog Tutorial

Hi Reuben and Cricket,

At least, something is working. While I've posted this issue here in the groups I started to backtrace the problem. What I've done now, is import the .htacces in /root/ to my web.config in /root/ AND copy the recommended web.config from the CakePHP book into the web.config in /root/. At least I can see the pages, and use the pretty URLS. But, I'm not there yet. 

As you can see, at http://dev-ov-ervaringen.nl/ the webpage is loading. At http://dev-ov-ervaringen.nl/index.php the page is loading as well, BUT with errors. The /index.php is situated in root/app/webroot/, if I'm not mistaken, right? Even http://dev-ov-ervaringen.nl/posts/index/ is working (only, I've got a nasty PHP error there. Have to figure out what that's supposed to mean, 'cause it's a litteral copy from the tutorial). 

What I think, is that I have to add some extra rules to my web.config in /app/ and in app/webroot. But, I don't have a clue yet. I'll keep searching and you informed. 

Jorick.

Op vrijdag 30 november 2012 01:32:47 UTC+1 schreef Reuben het volgende:
My guess is there is a problem with the web.config and URL rewrites.

The web.config files you have, don't quite look like the recommended web.config at http://book.cakephp.org/2.0/en/installation/advanced-installation.html

Unfortunately, I've not played with CakePHP on IIS7 using this method of URL redirect.

Actually, it could be a permissions issue.  Visiting http://dev.ov-ervaringen.nl/index.php yields an error that looks like CakePHP is correctly determining the controller name (but this one doesn't exist).  So if  the PostsController was being found, it might not be executable/readable, due to permissions on that file.

Regards
Reuben Helms

On Thursday, 29 November 2012 22:44:38 UTC+10, Jorick de Lange wrote:
Hi everyone,

So, I (we, actually) decided to create a website. Because of the need to extend later on, we decided to use a framework. CakePHP looked very well to fit our needs. Installed it, configured it, and after some .htacces import to web.config files, it was functional! See http://dev.ov-ervaringen.nl/ for the default page of CakePHP. 

Happy as I was, I started to follow the blog tutorial. Created the desired pages and I came to the point where you actualy can see the magic happen: I browsed to http://dev.ov-ervaringen.nl/posts/index/ and... Nothing. OK, back to the tutorial, to make sure I didn't make a typo. Nothing. Everything seems fine. 

Now, I'm stuck. I don't have a clue where to search for the problem. 

Here are the files:

in app/Controller/PostsController.php
class PostsController extends AppController { 
public $helpers = array('Html', 'Form');
    
    public function index() {
$this->set('posts', $this->Post->find('all'));
}
}

in app/Model/Post.php 
class Post extends AppModel {
}

in app/View/Posts/index.ctp 
<!-- File: /app/View/Posts/index.ctp -->
<h1>Blog posts</h1>
<table>
<tr>
    <th>Id</th>
        <th>Title</th>
        <th>Created</th>
    </tr>
    
    <!-- Here is where we loop through our $posts array, printing out post info -->
    
    <?php foreach ($posts as $post): ?>
<tr>
    <td><?php echo $post['Post']['id']; ?>></td>
        <td>
        <?php echo $this->Html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['post']['id'])); ?>
</td>
        <td><?php echo $post['Post']['created']; ?></td>
</tr>
    <?php endforeach; ?>
<?php unset($post); ?>
</table>

And, my web.config files:

in root:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="Default.aspx" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^$" ignoreCase="false" />
                    <action type="Rewrite" url="app/webroot/" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <action type="Rewrite" url="app/webroot/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

in app/
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <rewrite>
            <rules>
<remove name="Imported Rule 1"/>
<remove name="Imported Rule 2"/>
                <rule name="app 1" stopProcessing="true">
                    <match url="^$" ignoreCase="false" />
                    <action type="Rewrite" url="webroot/" />
                </rule>
                <rule name="app 2" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <action type="Rewrite" url="webroot/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

in app/webroot/
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
<remove name="app 1"/>
<remove name="app 2"/>
                <rule name="App Webroot 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

---

Is there anyone who is seeing the problem and has the solution to solve it?

Thanks in advance,

Jorick. 


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: