0

I've read several places trying to use ZendFramework directly from htdocs (without creating virtual servers) for every test environment I use. This is a development environment, that's the reason I don't care about security issues nor want to modify the hosts file every time. I work on Windows using xampp 1.7.3

I recreate the zend structure but inside a folder into htdocs. Lets say: C:\xampp\htdocs\project

By now, I found a solution using the following .htaccess in the projects root

RewriteEngine On
RewriteRule ^(.*)$ public/$1?%{QUERY_STRING} [QSA,L]

Inside C:\xampp\htdocs\project\public I use the default's Zend .htaccess

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

In my layout I add the base tag to redirect img, css and js links. My problem arises when I try to include a css font to my project (woff file) that's been redirected anywhere in the htaccess rules resulting in a 400 error code.

So my question is: What's wrong here? how can I redirect every controller (php file) but no any other existing file

By the way... I can't find the way to make htaccess files work by my own. I've always found myself searching for help :(

Thanks in advance

Alwin Kesler
  • 1,450
  • 1
  • 20
  • 41

1 Answers1

0

The simplest solution to your issue is to structure your files like this:

  • Put the contents of the public/ folder (index.php, .htaccess) in C:\xampp\htdocs\project. You will not have a public folder. For the purposes of this application, project/ is your public folder.
  • Put the application/ folder in C:\xampp\htdocs.
  • For extra security add a .htaccess file containing Deny from all in the application/ folder since it isn't outside the document root.

This should allow you to use the stock ZF .htaccess rules and not require you to use any RewriteBase or base URLs for loading your CSS/JS files.

Just make sure anywhere you want to reference a URL in your layout or views to use the baseUrl helper (e.g. <img src="<?php echo $this->baseUrl('images/foo.png') ?>" />)

drew010
  • 68,777
  • 11
  • 134
  • 162
  • Thanks for your time. I don't think this could be a posibility because I want to recreate a production environment and joining the application folder from multiple development/testing applications in the htdocs root can lead me to unexpected behavior – Alwin Kesler Aug 31 '12 at 20:07
  • In that case can you rename the application directory and then edit `index.php` to use the renamed directory, or move it out of docroot and change index.php to use the new path? – drew010 Sep 01 '12 at 00:54