I am using zend framework with Apache sever on U开发者_开发百科buntu. 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
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.
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
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.
精彩评论