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?

1 Answer 1

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]
1
  • 1
    You are a machine, @carlcs.
    – Brad Bell
    Aug 16, 2014 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.