Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place zend framework application in a wordpress website

Recently I created an application (sales portal) in PHP for a small company. The company had a website developed in word press. Since I hadn't worked with word press the way I embedded my application in the website is I simply created a sub directory on the host and uploaded my application there. E.g:

domainname.com - their website

domainname.com/portal - is where my application is placed (the 'index.php' file).

Since a month I am learning Zend Framework 1.8 and I want to rewrite the portal in Zend framework since I wrote the portal from scratch and its core is not as secure as it would be if it implements the Zend framework.

My question is can I include the Zend framework application into the wordpress website the way I did it with 'from-scratch' application, by creating a sub directory on the host and upload the application there? And if yes how should I configure the Zend application so that it recognizes 'domainname.com/portal' as the domain name (as home directory).

The problem that I face right now is that when I type http://www.domainname.com/portal/sales it returns 404 because there is not such directory on the server. Of course what I mean with the above mentioned link (domainname.com/portal/sales) is:

site: domainname.com/portal controller: sales action: index

I tried 'domainname.com/portal/index.php/sales' but when someone opens the portal with this link 'domainname.com/portal/' the next linked that is clicked (e.g. domainname.com/portal/sales) shows 404.

(note: the website http://www.domainname.com should be accessible also)

Thanks in advance.

like image 703
Stoyan Dimov Avatar asked Oct 08 '22 11:10

Stoyan Dimov


2 Answers

I believe that wordpress ues a .htaccess to redirect all URLs to its index.php.

This is the .htaccess I pulled out of a test installation:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

In your case, you would need to modify the .htaccess file so that it does not care about what's in http://domainname.com/portal.

In your case, your .htaccess file could look at this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} "/portal/"
RewriteRule (.*) $1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

Basically, what this does is that it ignores the subfolder 'portal' and doesn't process it with any of the normal rules.

However, there might be a down side: If future versions of wordpress updates the .htaccess file, then you will need to make those changes to the file again.

like image 180
F21 Avatar answered Oct 13 '22 11:10

F21


[C]an I embed the Zend framework application into the wordpress website the way I did it with 'from-scratch' application, by creating a sub directory on the host and uploading the application there?

Yes you can.

[H]ow should I configure the Zend application so that it recognizes domainname.com/portal as the domain name (home directory)[?]

Sure, please see Base Url and Subdirectories­Docs how you need to configure your request/routing for your Zend Framework based application.

like image 43
hakre Avatar answered Oct 13 '22 11:10

hakre