Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-26-2007, 10:30 PM
Junior Member
 
Join Date: Dec 2007
Location: Mornington, Victoria Australia
Posts: 3
Send a message via Skype™ to GeoffreyB
Default Problem with ZF URL

I am a real newbie. I am having a problem with ZF URLs.

Setup: Apache has an alias to the iris/html directory in my development area. My directory structure for this application is -
Code:
iris/application/controllers
                               /models
                               /views/filters
                                        /helpers
                                        /scripts/error
                                                  /index
                                                  /user
              /html/images
                      /scripts
                      /styles
              /library
.htaccess file in iris/html reads:
Code:
RewriteEngine on
RewriteRule !\\.(js|ico|gif|jpg|png|css)$ index.php
index.php is in iris/html and reads:
Code:
<?php
/**
 * My new Zend Framework project
 *
 * @author
 * @version
 */

set_include_path('.' . PATH_SEPARATOR . './library' . PATH_SEPARATOR . './application/models/' . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Controller/Front.php';
error_reporting( E_ALL | E_STRICT );

/*
 * Register an autoload() callback.  This is optional but very handy.
 */
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();

$appDir = dirname(dirname(__FILE__)) . '/application';
Zend_Registry::set('appdir', $appDir);

$config = new Zend_Config_Ini("$appDir/etc/config.ini",'main');
Zend_Registry::set('config', $config);


/*
 * This application uses a database, and our config file contains some
 * parameters to connect to the database.  Once we create this database
 * adapter, save it in the registry and also tell the table class where
 * to find it.
 */
$db = Zend_Db::factory(
    $config->database->adapter,
    $config->database->params->toArray()
);

/*
 * The database we're using has utf-8 characters, so encode them properly
 */
$db->query('SET NAMES utf8');

/*
 * Save this database connection in a place where other classes can find it.
 */
Zend_Registry::set('defaultDb', $db);
Zend_Db_Table::setDefaultAdapter('defaultDb');
/**
 * Setup controller
 */
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory("$appDir/controllers");
$controller->throwExceptions(true); // should be turned on in development time

// run!
$controller->dispatch();
My problem is that to access the index page I have to type the full url -
Code:
http://localhost/iris/index.php
Code:
http://localhost/iris/
gives me a
Code:
400 Bad Request

Your browser sent a request that this server could not understand.
response.
Like wise from the login form
Code:
<form name="form1" method="post" action="/iris/user/login">
produces the same 400 response.
Has anyone got some ideas about what I can do to fix this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-28-2007, 12:36 AM
Junior Member
 
Join Date: Jan 2007
Posts: 3
Default

Hi Geoffrey,

Try removing one of the back-slashes in your .htaccess and see if that helps.

Also, does your Apache error log give any clues?

Thanks,
Al.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-28-2007, 03:22 AM
Junior Member
 
Join Date: Dec 2007
Location: Mornington, Victoria Australia
Posts: 3
Send a message via Skype™ to GeoffreyB
Default Thanks Al

Thank you. This has fixed another issue, the /styles/style.css file is now being applied.
I can now access the index page using http://localhost/iris/index but still not via http://localhost/iris/ and likewise the other pages eg http://localhost/iris/user/login.

Apache error.log doesn't help too much
Code:
[Fri Dec 28 13:34:07 2007] [error] [client 127.0.0.1] Invalid URI in request GET /iris/ HTTP/1.0
[Fri Dec 28 13:37:29 2007] [error] [client 127.0.0.1] Invalid URI in request POST /iris/user/login HTTP/1.0, referer: http://localhost/iris/index.php
Any other ideas greatly appreciated.

Geoffrey
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-10-2008, 04:09 AM
Junior Member
 
Join Date: Jan 2008
Posts: 2
Default

I have the exact same setup with an Alias and running into the very same problem. I can get to the page fine via http://localhost/alias/index.php, but getting 400 Bad Reqests on any other requests such as http://localhost/alias/ or http://localhost/alias/index/index.

Any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-10-2008, 04:24 AM
Junior Member
 
Join Date: Jan 2008
Posts: 2
Default

Of course after searching for at least an hour, I find the solution 2 minutes after posting.

RewriteBase /alias
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-10-2008, 04:35 AM
Junior Member
 
Join Date: Dec 2007
Location: Mornington, Victoria Australia
Posts: 3
Send a message via Skype™ to GeoffreyB
Default

Quote:
Originally Posted by bricks View Post
Of course after searching for at least an hour, I find the solution 2 minutes after posting.

RewriteBase /alias
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Thanks a heap.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:00 PM.