views:

475

answers:

3

I am using zend framework with Apache sever on Ubuntu. When I try my site on localhost, I use following url

for example:

http://test.dev/authentication/login
http://test.dev/student/profile

Where 'authentication' refers to AuthenticationController and 'login' refers to loginAction. 'student' refers to StudentController and 'profile' refers to profileAction.

Question: Now I want to use phpBB forum with my site. I had to use the following URL to start phpBB forum with my website.

http://localhost/test/forum/

Where 'test' is my main project(website) directory. I want to use following URL for phpBB forum.

http://test.dev/forum/

How to configure my project to open phpBB forum using above URL? Should I create a controller?

Thanks

+2  A: 

I guess you are using apache mod_rewrite with your ZF application.

The simplest solution is to place a new .htaccess file inside the forum/ directory and turn off the rewrite engine

RewriteEngine Off

This works because Apache first look for the .htaccess file in the requested directory, if it does not find one, he looks in the parents folder and so on until it reaches the public directory. When you request /forum/ he finds the .htaccess file there and turns off the RewriteEngine.

Goran Jurić
I am using apache server. Can you tell that what should I write exactly in .htaccess file.thanks for response.
NAVEED
Please post your current .htaccess file so I can take a look at it.
Goran Jurić
SetEnv APPLICATION_ENV developmentRewriteEngine OnRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^.*$ - [NC,L]RewriteRule ^.*$ index.php [NC,L]
NAVEED
I have above lines in my .htaccess file in public folder. Sorry for all code in one line.
NAVEED
I have edited my answer with the solution to your problem.
Goran Jurić
Your answer helped me a lot. Thanks
NAVEED
I am glad it did. You can mark the answer as accepted if it helped you :)
Goran Jurić
can you check my answer. do you think it has any problem/bug :)I have voted your answer.
NAVEED
A: 

After some time I have found my answer. I just placed my 'forum' folder in 'public' folder and it is working for me without changing my .htaccess file.

Here is my settings:

My directory structure is now like this:

/var/www/test/public/index.php
/var/www/test/public/.htaccess
/var/www/test/public/forum

My httpd.conf entry is like this:

<VirtualHost 127.0.0.1>
    ServerName test.dev
    DocumentRoot 'C:\wamp\www\test\public'
</VirtualHost>

My .htaccess file is like this(it controls both folder and controller/action URLs):

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]

Last line in above .htaccess file allow me to use my URL without index.php in URL.

After above setting I am able to use following URLs correctly:

http://test.dev/authentication/login
http://test.dev/student/profile
http://test.dev/forum/

In above URLs 'authentication' and 'student' are controllers. 'login' and 'profile' are actions and forum is a directory

Comments are welcome. Thanks

NAVEED
+1  A: 

This will work as well:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php

If you place phpBB in the public folder the webserver will be able to see it and the 2nd two lines of this code will exclude "real files" and "real folders" from the rewrite which is what you want for the forum folder. Obviously the last time, pushes all framework traffic to the index.php file.

danielrsmith
Thanks for your response.
NAVEED