Wordpress inside Cakephp - wordpress

I have installed Wordpress inside Cakephp's /app/webroot/blog/ folder and changed the wordpress permalink settings to Month and name (eg. http://abc.com/blog/2013/02/sample-post/).
Now when i am viewing a post i am getting Missing Controller(Error: BlogController could not be found).
I want to change the cakephp routes so that anything with /blog/* will point to webroot blog folder.
Can anybody help me on this?

When we change the permalink settings of Wordpress, it generates a .htaccess file, if there is required permission else we have to create it.
In the above case there was no .htaccess file inside /blog/ folder. I created it with the following mod_rewrite rules as provided by Wordpress while changing permalink settings.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
After this every thing works fine.

There is no need to put the blog folder in webroot folder. You can access your folder by making slight changes in your .htaccess file. Just put your wordpress folder on root of cakephp with app folder and change .htaccess as given below.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (blog/.*) $1 [L] # adjust the regex to what you want.
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

I tried both the above codes but none work for me.. then i found something by my own and it worked..So here it is ,, hope this will help some.
First Add the WordPress folder inside the webroot folder as blog. Inside blog paste the WordPress directories and files.. install the WordPress.. Now you will see in the WordPress admin general settings WordPress Address as http://cakephp/blog/app/webroot/blog, Change it to http://cakephp/blog. Save it ..
Now look for the .htaccess file in WordPress install root folder change RewriteBase and RewriteRule (last one ) to RewriteBase /blog/ and RewriteRule . /blog/index.php [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

Related

Can't access 2nd Wordpress instance in subdirectory

I've installed a second instance of wordpress in a subdirectory but when I try to access mysite.com/newsite I get a 404 error page on the root wordpress install page/theme. I've looked at the .htaccess files which have rewrite rules, tried adding an exception for the /newsite folder in the root .htaccess but it had no effect.
Can someone help with this?
Did you try this set of instructions? According to that site, the .htaccess in the second installation should look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /newsite/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /newsite/index.php [L]
</IfModule>
# END WordPress
Try that out if you haven't and let me know if it works.

htaccess rewrite issue excluding folder

I have a Wordpress site that has a rewrite rule. I also have a non-wordpress folder, but I can't access it because of this rule. So I read that i should enter RewriteEngine Off in the htaccess of the non-wordpress folder, unfortunately I still get an Error 404 on that page (it works fine if I remove the Wordpress rewrite).
Here is the htaccess in the root:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
What am I doing wrong?
Many thanks!
Matt
Add this right under RewriteBase /:
RewriteRule ^folder/ - [L]
where folder is the folder you want to exclude.

Wordpress migration and htaccess file

I need to migrate a wordpress from http://myoldwebsite.com/blog to http://newwebsite.com/.
I have htaccess file as follows. Am I right if I change
RewriteBase /blog/ to RewriteBase /
RewriteRule . /blog/index.php to RewriteRule . /index.php
My .htaccess code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Just use a migration plugin, like WP Migrate, to export the DB.
After you are done with the DB import, don't forget to go to Settings->Permalinks and just hit save button, in order to have .htaccess updated.
Done.
Unfortunately it's not as simple as just changing the .htaccess file.
From the Wordpress codex:
When your domain name or URLs change - i.e. from
http://example.com/site to http://example.com, or http://example.com
to http://example.net - there are additional concerns. The files and
database can be moved, however references to the old domain name or
location will remain in the database, and that can cause issues with
links or theme display.
The most important change which most trips up a lot of people is to change "siteurl" and "home" in the "wp_options" table to point to your new address.
Yes you can add the following to htaccess file. If you are migrate a wordpress from http://myoldwebsite.com/blog to http://myoldwebsite.com/
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Note You have to change URL in database also.
If you want to migrate a wordpress from http://myoldwebsite.com/blog to http://newwebsite.com/. You can use followin plugin to migrate
Plugin link

Wordpress Permalink Custom Url /index.php/%postname is working while /%postname is not working

I have uploaded my website to the server and when i am trying to change permalink, it is working only with /index.php/%postname.
Neither /index.php/%postname/% is working nor /%postname/* is working.
Thanks in advance....
put below code in .htaccess file in wordpress site directory. verify similar code is already present in .htaccess file or not. If present please replace with below code. if no .htaccess file is present please create one with following code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

htaccess issue with website having WordPress directory containing Cakephp website

I am working on website having front website made with WordPress and a WordPress directory
contains a dashboard folder having a cakephp website. Everything is working perfectly on my
local system but when I migrated the whole website to online server I am unable to access
www.mywebsite.com/dashboard folder as I read here
https://wordpress.stackexchange.com/questions/20152/cannot-access-non-wordpress-subdirectories-as-wordpress-overrides-them-with-a-40
this is a htaccess issue but I dont know htaccess coading at all so this link was confusing
to me if any one could explain me (in simple way) why this problem occurs? and how to
solve this problem? will be helpfull to me
my wordpress htaccess is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
and cakephp htaccess which is in wordpress-install-directory/dashboard/cakephp-install
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
It should be just a case of changing your .htaccess to match the below
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase wordpress-install-directory/dashboard
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Doing the above will tell cake that the needed files are within instal-directory/dashboard.
You will also need to make the same change to webroot and app .htaccess
If they are in different folders with independent .htaccess files, you might try to set the base directory for cakephp, like this:
<IfModule mod_rewrite.c>
RewriteEngine on
# Could be dashboard or cakephp-install
RewriteBase /dashboard
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
From a stackoverflow answer here:http://stackoverflow.com/questions/2322559/htaccess-wordpress-exclude-folder-from-rewriterule/2350305#2350305
add
RewriteCond %{REQUEST_URI} !^/(dashboard|dasboard/.*)$
before the last RewriteRule on your .htaccess file on wordpress directory and it should work.

Resources