Aji
Aji

Reputation: 25

CakePHP routing exception in .htaccess file still results in missing controller error

I have a CakePHP 2 install but have certain URLs exempt from the default routing. I did this by adding the exception to the .htaccess file. So for example the call the http://www.mydomain.com/blog or http://www.mydomain.com/proofgallery both redirected to a folder outside of the cakephp.

The .htaccess code looks like this:

# Overrides to the cake routing    
<IfModule mod_rewrite.c>
  RewriteEngine On
RewriteCond %{REQUEST_URI} ^/?  (blog|proofgallery)/(.*)$
  RewriteRule ^.*$ - [L]
</IfModule>

However, I noticed in the error.log that something causes a missing controller error for those exemptions.

E.g.

2012-10-16 14:49:15 Error: [MissingControllerException] Controller class ProofgalleryController could not be found.
#0 /home/mydomain/public_html/app/webroot/index.php(96): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}

2012-10-16 11:13:24 Error: [MissingControllerException] Controller class BlogController could not be found.
#0 /home/mydomain/public_html/app/webroot/index.php(96): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))

#1 {main}

Why is that? And how to avoid it? As far as I can tell, all links from within the application use the full URL (http://www.mbvphotography.com/blog) and not the Cake HTML helper, which might explain the missing controller error.

Upvotes: 1

Views: 2218

Answers (1)

Pedro
Pedro

Reputation: 691

I imagine that you want to add other code but you want to still use Cakephp.

According this your examples, if you want to add http://www.mydomain.com/blog you must go to the following path "app/webroot" of CakePHP and add the folder "blog". For example if you want to use a wordpress with your CakePHP aplication.

Verify that you have the default .htacces on app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

And remove the changes you made on the .htaccess.

I If you have more doubts let me know

Upvotes: 2

Related Questions