How to redirect /app/webroot/blog/ into /blog/ WordPress Cakephp
At this time, a company website normally should have blog to post some business activity or related activity with website themes. WordPress is the best blog framework (CMS) that i ever used. When i was build web application under my own php framework, i wasn’t worried about integrating wordpress into my website. It would has separated setting with main application.
However, now i am using cakephp framework. And if we need to put file or folder, it need to be put inside app/webroot folder. So if i need to install wordpress blog in http://www.balistupa.com/blog, i need to put the blog folder inside /app/webroot/.
The problem is about the url, with standard setting the blog would be redirected to http://www.balistupa.com/app/webroot/blog/ not to http://www.balistupa.com/blog/. This is not look good for visitor and also for seo. Because the folder structure is to deep.
After researching, i play with .htaccess setting to redirect /app/webroot/blog/ into /blog/ url. And the solution is very simple. So this is the step how i install wordpress blog inside cakephp framework.
- upload wordpress files into /app/webroot/blog/ folder on server
- setting /app/webroot/blog/wp-config.php with appropriate setting for database
- and then install wordpress. On this step you will get directed to http://www.yourdomain.com/app/webroot/blog/wp-admin/install.php. Dont worried about the path, we can fix it easily
- After installation finished, go to wordpress admin area at http://www.yourdomain.com/app/webroot/blog/wp-admin and then log in
- Go to Settings > General. Change WordPress address (URL) and Site address (URL) into http://www.yourdomain.com/blog/ and then Save.
- If using mod_rewrite for wordpress, Open /app/webroot/blog/.htaccess. Change into
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/webroot/blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /app/webroot/blog/index.php [L]
</IfModule> - Open /.htaccess, Change its setting into
RedirectMatch temp ^/blog/wp-admin$ http://www.yourdomain.com/blog/wp-admin/
RewriteRule blog$ /blog/ [L]
RewriteRule blog/wp-admin$ /blog/wp-admin/ [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L] - Finished. Now you will have wordpress blog url at http://www.yourdomain.com/blog/
I notice that this setting also fix the problem user access http://www.yourdomain.com/blog without end /, and redirected into http://www.yourdomain.com/blog/.
So that is how we can redirecting http://www.yourdomain.com/app/webroot/blog/ into http://www.yourdomain.com/blog/ for installing WordPress blog inside Cakephp Framework
if you put your blog in document root you can use:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/blog.*
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/blog.*
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) app/webroot/$1 [L]
Comment by michas — August 3, 2010 @ 2:26 pm
@michas: thank you michas, you solved another problem for installing wordpress at document root which cakephp installed there
Comment by admin — August 3, 2010 @ 7:47 pm
This tutorial is absolutely right but there have a little mistake
when you going to install wordpress try this
this line content a little mistake
3. and then install wordpress. On this step you will get directed to http://www.yourdomain.com/app/webroot/blog/install.php. Dont worried about the path, we can fix it easily.
this line is mistake free.
3. and then install wordpress. On this step you will get directed to http://www.yourdomain.com/app/webroot/blog/wp-wp-admin/install.php. Dont worried about the path, we can fix it easily.
Comment by Sourav Mondal — November 19, 2010 @ 5:38 am
@Sourav Mondal: thank you, you are right
Comment by admin — November 19, 2010 @ 5:46 am
i changed settings from wp-admin as you said.. i opened front-end perfectly but it changed my admin password.. i tried it many times every time this problem ruined my way..
can you tell me what is it problem?
Comment by Tahir — June 1, 2012 @ 5:12 am
This was REALLY helpful! I couldn’t figure out why it kept adding the extra directories for the blog. It did, though, take me a second to figure out where the /.htaccess file was, since I wasn’t entirely sure if the root was the /app directory, or the one before. For anyone wondering, it’s the /html directory in CakePHP, or at least the one I have.
Thanks again for the help.
Comment by Joseph — March 20, 2013 @ 3:31 pm