Home » Software Development

Fixing a rewrite issue in WordPress and Zend Framework

8 November 2012 One Comment

While working on an application for a client, I was faced with below rewrite issue.
The client was using WordPress as the CMS and wanted a restful API service which i had to develop for them.

The requirement was to develop Rest API using Zend Framework.
Once I have written the Rest API, I had some conflicting issues with rewrite rules.

The WordPress application was installed at the web root directory whereas the API service was on a sub-folder /api

So a rest uri with http://www.domain.co.nz/api/account/1234 was giving a 404 WordPress error. I had a look at WordPress .htaccess file but it contained tonnes of rules for W3 Total Cache plugin for WordPress.

I did not want to even touch WordPress .htaccess file so i tried to modify only /api/.htaccess file.
After a bit of tweaking i managed to get the api working. Below are the rewrite rules.


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

Hope this helps someone working on Zend and WordPress on same server root.

One Comment »

  • Iso consultancy said:

    Simply wish to say your article is as surprising. The clearness on your post is just excellent
    and that i can assume you are a professional in
    this subject. Fine together with your permission let
    me to seize your RSS feed to keep up to date with approaching post.
    Thanks 1,000,000 and please keep up the enjoyable work.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image