7

Unfortunately, I'm in a position where I need to run a Craft and WordPress installation out of the same directory. The WordPress install is under the sub-directory /blog.

When I visit http://mysite.dev/blog/ the WordPress blog loads as expected, but attempts to visit any routes within that result in Craft's 404 page. For instance, http://mysite.dev/blog/my-post.

Is it possible to convince Craft to ignore any requests under /blog?

Brad Bell
  • 67,440
  • 6
  • 73
  • 143
cmal
  • 815
  • 4
  • 14

1 Answers1

4

Have a look at the Routing article in the Craft Documentation, it describes why Craft handles these request in the first place:

The .htaccess file that comes with Craft will redirect all would-be 404 requests over to index.php behind the scenes, which is why Craft is able to respond to URLs that don’t point to any actual folder/file in your web root.

A fresh Craft install's .htaccess file looks like so:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>

You'll notice that favicons are removed from the redirect. Add a similar RewriteCond for blog/ to also exclude request to your WordPress folder from this condition.

    RewriteCond %{REQUEST_URI} !blog [NC]
carlcs
  • 36,220
  • 5
  • 62
  • 139