Mailinglist Archive: opensuse (3441 mails)

< Previous Next >
Re: [opensuse] Access Forbidden with AllowOverride All Enabled
  • From: Graham Anderson <graham.anderson@xxxxxxxxx>
  • Date: Fri, 16 Jan 2009 07:38:15 +0100
  • Message-id: <200901160738.15595.graham.anderson@xxxxxxxxx>
On Friday 16 January 2009 05:36:18 Anthony M Simonelli wrote:
I've configured Apache, but it seems that the AllowOverride directive,
set to "All", causes my Apache2 to only serve up Access Forbidden. Is
there a reason for this? Changing it back to "None" displays the pages
but ignores .htaccess files. I have a PHP framework that uses header
rewrites so I'd like to get that functionality working.

--
Anthony M Simonelli <asimonelli01@xxxxxxxxx>

I'd suggest checking your logs (/var/log/apache2) to see what caused the
offending 403. And in case you have not enabled it already you'll need
"Options FollowSymlinks" directive in your <directory> section ( or your
.htaccess), mod_rewrite requires this.

A typical basic vhost to get a quick development app up and running with a
fremework that uses url rewriting (Zend Framework for example) might look
something like this.

<VirtualHost *:80>
DocumentRoot /srv/www/htdocs/mysite/public
ServerName pastebin
ServerAdmin root@localhost
<Directory /srv/www/htdocs/mysite/public >
AllowOverride All
Order allow,deny
Allow from all
Options FollowSymlinks
</Directory>
</VirtualHost>

Here is a sample directory structure in /srv/www/htdocs/mysite for a framework
site using mod_rewrite

mysite
public
.htaccess
index.php
application
bootstrap.php
library
Zend

and then a basic .htaccess

# Redirect options
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
</IfModule>

This .htaccess does the following, checks the following conditions

The requested URL points to a resource that is an existing file (-s), symbolic
link (-l) or a directory (-d). So basically if a client browser is asking for
http:://mysite.com/images/image.jpg and image.jpg exists it will serve it. If
not it will perform a local, case insensitive redirect to index.php.

index.php typically would be where you either launch a bootstrap or directly
try and dispatch from the frameworks front controller class/object.

To launch your application from a bootstrap index.php simply needs one line.

<?php
require_once dirname( getcwd() ) . '/application/bootstrap.php;


To do a simple bootstrap directly from index.php I'll use Zend Framework as an
example but the process should be similar for other PHP frameworks.

<?php
set_include_path(
dirname( getcwd() ) . '/library' . PATH_SEPARATOR . get_include_path() )
);

require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();

$front = Zend_Controller_Front::getInstance();

...
configure front controller, environment, routes, plugins, whatever
...

$front->dispatch();

Regards
Graham
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
References